diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSubscriptionPlans.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSubscriptionPlans.sql new file mode 100644 index 0000000..c7ec30d --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_GetSubscriptionPlans.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertSubscriptionPlan.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertSubscriptionPlan.sql new file mode 100644 index 0000000..7bec445 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_InsertSubscriptionPlan.sql diff --git a/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateSubscriptionPlan.sql b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateSubscriptionPlan.sql new file mode 100644 index 0000000..0540a18 --- /dev/null +++ b/150-DOCUMENTATION/002-DBScripts/Admin/Store Procedure/usp_UpdateSubscriptionPlan.sql diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/DiscountCodeController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/DiscountCodeController.cs index 721a25b..93b4b9b 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/DiscountCodeController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/DiscountCodeController.cs @@ -17,7 +17,7 @@ using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Controllers { - [EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] [RoutePrefix("DiscountCode")] public class DiscountCodeController : ApiController { diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/SubscriptionPriceController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/SubscriptionPriceController.cs index 7a63fc9..44bdebf 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/SubscriptionPriceController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/SubscriptionPriceController.cs @@ -17,7 +17,7 @@ using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Controllers { - [EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] [RoutePrefix("SubscriptionPrice")] public class SubscriptionPriceController : ApiController { diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs index fb7d917..d35ac87 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs @@ -16,7 +16,7 @@ using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Controllers { - [EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] + //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] [RoutePrefix("User")] public class UserController : ApiController { diff --git a/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.html b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.html new file mode 100644 index 0000000..b27e17f --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.html @@ -0,0 +1,231 @@ +
+ +
+

Subscription Price

+
+ + + + + + + + + + + + + + + +
+ +
+ +
+
+ +
+
+
+
+
+
+
+ +
+ + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + +
SelectSubscription TypeDuration(in Month)PriceActive
+ + + + {{item.Title}}{{item.Duration}}{{item.Price | number : '1.2'}} + +
+
+
+ + +
+
+ + + +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+ +
+ + + +
Subscription title is required
+
+
+ +
+ +
+ +
Subscription price is required
+
Subscription price must be numeric
+
+
+ +
+ +
+ +
Subscription duration is required
+
Subscription duration must be numeric
+
+
+ +
+ +
+ + +
+
+ +
+
+ + +
+
+ +
+ + + + + + + + + + +
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts new file mode 100644 index 0000000..5e75630 --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts @@ -0,0 +1,182 @@ +import { Component, OnInit, AfterViewInit, Input, Output, EventEmitter, OnChanges, + SimpleChanges, TemplateRef, Pipe, PipeTransform } from '@angular/core'; +import { SubscriptionPriceService } from './subscriptionprice.service'; +import { Router } from '@angular/router'; +import { FormControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { SubscriptionPriceModel } from '../UserEntity/datamodel'; +import { BsDatepickerModule } from 'ngx-bootstrap'; +import { Http, Response } from '@angular/http'; +import { DatePipe } from '@angular/common'; +import { ContenteditableModelDirective } from '../../shared/contenteditabledirective' +import { BsModalService } from 'ngx-bootstrap/modal'; +import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; +//import { Global } from '../../Shared/global'; +//import { DBOperation } from 'S'; +//import { Observable } from 'rxjs/Observable'; + +@Component({ + templateUrl: './subscriptionprice.component.html' +}) + +export class SubscriptionPrice implements OnInit { + +Mode: string = 'Search'; +subscriptionPrice: SubscriptionPriceModel; +subscriptionPrices: Array; +subscriptionPriceFrm: FormGroup; +insertSubscriptionPriceFrm: FormGroup; +checkedRecords: Array; +error: any; +alerts: string; +modalAlerts: string; +topPos: string = '2000px'; +datePipe: DatePipe = new DatePipe('en-US'); +selectedEditionId: number = 1; +divClass: string = ''; +modalRef: BsModalRef; + +constructor(private subscriptionPriceService: SubscriptionPriceService, private router: Router, private fb: FormBuilder, private modalService: BsModalService) { } + + ngOnInit(): void { + this.divClass = 'col-sm-12'; + this.subscriptionPrice = new SubscriptionPriceModel(); + this.alerts = ''; + this.subscriptionPriceFrm = this.fb.group({ + subscriptionPrices: this.fb.array([]) + }); + this.insertSubscriptionPriceFrm = this.fb.group({ + subscriptionPriceId: [''], + title: ['', Validators.required], + price: ['', [Validators.required, Validators.pattern('[0-9.]*')]], + duration: ['', [Validators.required, Validators.pattern('[0-9]*')]], + editionId: [''], + isActive: [false] + }); + this.SearchSubscriptionPrices(this.selectedEditionId); + } + + public SearchSubscriptionPrices(searchEditionId: number) { + this.selectedEditionId = searchEditionId; + this.subscriptionPriceService.GetSubscriptionPrices( + { + editionId: this.selectedEditionId, + }) + .subscribe(x => { this.BindFormFields(x) }, error => this.error = error); + } + + openModal(template: TemplateRef) { + if(this.checkedRecords.filter(C => C > 0).length == 0) return; + this.modalRef = this.modalService.show(template); + } + + onChange(Idx: number, Id: number, isChecked: boolean){ + if(isChecked){ + this.checkedRecords[Idx] = Id; + } + else{ + this.checkedRecords[Idx] = 0; + } + } + + AfterDeleteData(data, template) { + if (data.Status == "false") { + this.alerts = "Subscription prices delete unsuccessfull"; + } else { + this.modalAlerts = "

Subscription prices deleted successfully

"; + this.modalRef = this.modalService.show(template); + this.SearchSubscriptionPrices(this.selectedEditionId); + } + } + + AfterInsertData(data, template) { + if (data.Status == "false") { + this.alerts = "Subscription price save unsuccessfull"; + } else { + this.modalAlerts = "

Subscription price saved successfully

"; + this.modalRef = this.modalService.show(template); + } + } + + AfterUpdateData(data, template) { + if (data.Status == "false") { + this.alerts = "Subscription prices update unsuccessfull\n"; + } else { + this.modalAlerts = "

Subscription prices updated successfully

"; + this.modalRef = this.modalService.show(template); + } + } + + BindFormFields(data){ + this.subscriptionPrices = data; + this.checkedRecords = new Array(this.subscriptionPrices.length); + this.subscriptionPriceFrm.setControl('subscriptionPrices', this.fb.array(this.subscriptionPrices)); + } + + UpdateSubscriptionPrices(template: TemplateRef){ + console.log(this.subscriptionPriceFrm.value); + this.alerts = ''; + if(this.alerts == ''){ + var obj = this.subscriptionPriceFrm.controls['subscriptionPrices'].value; + this.subscriptionPriceService.UpdateSubscriptionPrices(obj).subscribe( + data => (this.AfterUpdateData(data, template)), + error => { + this.error = error; + this.alerts = "" + this.error + ""; + }); + } + } + + InsertSubscriptionPrice(template: TemplateRef){ + console.log(this.insertSubscriptionPriceFrm.value); + this.alerts = ''; + if(this.alerts == ''){ + var obj = this.insertSubscriptionPriceFrm.value; + return this.subscriptionPriceService.InsertSubscriptionPrice(obj) + .subscribe( + data => (this.AfterInsertData(data, template)), + error => { + this.error = error; + this.alerts = "" + this.error + ""; + }); + } + } + + DeleteSubscriptionPrices(template: TemplateRef){ + console.log(this.checkedRecords); + this.alerts = ''; + if(this.alerts == ''){ + var obj = this.checkedRecords.filter(C => C > 0); + return this.subscriptionPriceService.DeleteSubscriptionPrices(obj) + .subscribe( + data => (this.AfterDeleteData(data, template)), + error => { + this.error = error; + this.alerts = "" + this.error + ""; + }); + } + } + + AddSubscriptionPrice(){ + this.Mode = 'Add'; + this.topPos = '100px'; + this.divClass = 'col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3'; + this.insertSubscriptionPriceFrm.reset(); + this.alerts = ''; + this.insertSubscriptionPriceFrm.controls['subscriptionPriceId'].setValue(0); + this.insertSubscriptionPriceFrm.controls['title'].setValue(''); + this.insertSubscriptionPriceFrm.controls['price'].setValue(''); + this.insertSubscriptionPriceFrm.controls['duration'].setValue(''); + this.insertSubscriptionPriceFrm.controls['editionId'].setValue(this.selectedEditionId); + this.insertSubscriptionPriceFrm.controls['isActive'].setValue(false); + } + + CancelAdd(){ + this.Mode = 'Search'; + this.topPos = '2000px'; + this.divClass = 'col-sm-12'; + this.insertSubscriptionPriceFrm.reset(); + this.alerts = ''; + this.SearchSubscriptionPrices(this.selectedEditionId); + } + +} diff --git a/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts new file mode 100644 index 0000000..1ec813e --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts @@ -0,0 +1,79 @@ +import { Injectable, Inject } from '@angular/core'; +//import { HttpClient, HttpParams, HttpRequest} from "@angular/common/http"; +import { Http, Response, Headers, RequestOptions, HttpModule } from '@angular/http'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; +import 'rxjs/add/operator/do'; +import { Observable } from 'rxjs/Observable'; +import { GlobalService } from '../../Shared/global'; + +@Injectable() +export class SubscriptionPriceService { + + constructor(private http: Http, private commonService: GlobalService ) { } + + + GetSubscriptionPrices(obj: any) { + return this.http.get(this.commonService.SubscriptionBaseUrl + "/GetSubscriptionPrices?editionId=" + + obj.editionId) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } + + InsertSubscriptionPrice(obj: any) { + //let options = new RequestOptions({ headers: this.headers }); + var jsonData = {'id': obj.subscriptionPriceId, 'title': obj.title, 'price': obj.price, 'duration': obj.duration, 'editionId': obj.editionId, 'isActive': obj.isActive }; + console.log(obj); + var headers = new Headers({ + 'Content-Type': 'application/json' + }); + return this.http.post(this.commonService.SubscriptionBaseUrl + "/InsertSubscriptionPrice", + JSON.stringify(jsonData), {headers: headers}) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } + + UpdateSubscriptionPrices(obj: any) { + //let options = new RequestOptions({ headers: this.headers }); + var jsonData = { obj }; + console.log(obj); + var headers = new Headers({ + 'Content-Type': 'application/json' + }); + return this.http.post(this.commonService.SubscriptionBaseUrl + "/UpdateSubscriptionPrices", + JSON.stringify(jsonData), {headers: headers}) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } + + DeleteSubscriptionPrices(obj: any) { + //let options = new RequestOptions({ headers: this.headers }); + var subscriptionPriceIds = obj; + console.log(subscriptionPriceIds); + var headers = new Headers({ + 'Content-Type': 'application/json' + }); + return this.http.post(this.commonService.SubscriptionBaseUrl + "/DeleteSubscriptionPrices", + subscriptionPriceIds, {headers: headers}) + .map(this.extractData) + .catch((res: Response) => this.handleError(res)); + } + + extractData(res: Response) { + //debugger; + let body = res.json(); + return body; + } + + handleError(error: any) { + // In a real world app, we might use a remote logging infrastructure + // We'd also dig deeper into the error to get a better message + let errMsg = (error.message) ? error.message : + error.status ? `${error.status} - ${error.statusText}` : 'Server error'; + console.error(errMsg); // log to console instead + return Observable.throw(errMsg); + } + + +} diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html new file mode 100644 index 0000000..e6d5cfe --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html @@ -0,0 +1,122 @@ +
+ +
+

Add User

+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ + (Minimum 8 characters) +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + + + +
+ +
+
+ +
+
+
+
+
+
+
+
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts new file mode 100644 index 0000000..510ea88 --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts @@ -0,0 +1,120 @@ +import { Component, OnInit, AfterViewInit,ViewChild } from '@angular/core'; +import { UserService } from '../UserEntity/user.service'; +import { Router } from '@angular/router'; +import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { User } from '../UserEntity/datamodel'; +import { Http, Response } from '@angular/http'; +import { GlobalService } from '../../Shared/global'; +//import { DBOperation } from 'S'; +import { Observable } from 'rxjs/Observable'; +import { ConfirmService } from '../../Shared/Confirm/confirm.service'; +import 'rxjs/Rx'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/filter'; + + +@Component({ + templateUrl:'./adduser.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' +}) + +export class AddUser implements OnInit { + user: User; + baseUrl: string = "User"; + adduserFrm: FormGroup; + useFname: string; + error; + status: boolean; + alerts: string; + emailPattern = "^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"; + public UserTypeList: any; + public AccountNumberList: any; + public ProductEditionList: any; + modalTitle: string; + //@ViewChild("profileModal") + //profileModal: ModalComponent; + //errorMessage: any; + constructor(private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http, + private _confirmService: ConfirmService, private commonService: GlobalService + ) { } + + ngOnInit(): void { + this.user = new User(); + this.alerts = ''; + //this.userservice.GetUserById(this.UserId); + this.adduserFrm = this.fb.group({ + id: [''], + UserName: ['', Validators.required], + Password: ['', Validators.required], + ConfirmPassword: ['', Validators.required], + FirstName: ['', Validators.required], + LastName: ['', Validators.required], + EmailId: ['', Validators.required], + AccountNumberId: ['', Validators.required], + UserTypeId: ['', Validators.required], + ProductEditionId: ['', Validators.required] + }); + //this.GetAccountNumber(); + this.GetUserTypeByLicenseId(); + } + GetUserTypeByLicenseId() { + debugger; + var Accountnumber = this.adduserFrm.controls['AccountNumberId'].value; + if (Accountnumber == "") { Accountnumber=0} + this.userservice.GetUserTypeByLicenseType({ + AccountNumberId: Accountnumber + }).subscribe(x => { this.UserTypeList = x; }, error => this.error = error); + } + GetAccountNumber() { + + this.userservice.GetAccountNumber() + .subscribe(x => { console.log(x); this.AccountNumberList=x }, error => this.error = error); + } + GetProductEdition() { + this.userservice.GetProductEdition({ + AccountNumberId: this.adduserFrm.controls['AccountNumberId'].value}) + .subscribe(x => { console.log(x); this.ProductEditionList=x }, error => this.error = error); + } + UpdateUserProfile(this) { + // debugger; + this.user = this.adduserFrm.value; + //if(this.user.) + //console.log(this.user); + var obj = this.user + if (this.adduserFrm.valid) { + return this.userservice.UpdateUserProfileById(obj) + .subscribe( + n => (this.AfterInsertData(n)), + error => this.error = error); + } + } + AfterInsertData(data) { + //debugger; + if (data.Status == "False") { + return false; + } else { + this.status = true; + this._confirmService.activate("User Profile Updated Successfully.", "alertMsg"); + } + + } + bindUsers(data) { + + //console.log(data); + //alert(JSON.stringify(data)); + //this.user = data[0]; + + + this.adduserFrm.controls['id'].setValue(this.user.Id) + this.adduserFrm.controls['FirstName'].setValue(this.user.FirstName) + this.adduserFrm.controls['LastName'].setValue(this.user.LastName) + this.adduserFrm.controls['EmailId'].setValue(this.user.EmailId) + this.adduserFrm.controls['UserName'].setValue(this.user.LoginId) + this.adduserFrm.controls['Password'].setValue(this.user.Password) + this.adduserFrm.controls['ConfirmPassword'].setValue(this.user.ConfirmPassword) + this.adduserFrm.controls['AccountNumberId'].setValue(this.user.AccountNumberId) + this.adduserFrm.controls['UserTypeId'].setValue(this.user.UserTypeId) + this.adduserFrm.controls['ProductEditionId'].setValue(this.user.ProductEditionId) + + } +} diff --git a/400-SOURCECODE/Admin/src/app/shared/contenteditabledirective.ts b/400-SOURCECODE/Admin/src/app/shared/contenteditabledirective.ts new file mode 100644 index 0000000..ded3b1b --- /dev/null +++ b/400-SOURCECODE/Admin/src/app/shared/contenteditabledirective.ts @@ -0,0 +1,49 @@ +import { Directive, ElementRef, Input, Output, OnChanges, EventEmitter, HostListener, SimpleChanges +} from '@angular/core'; + +@Directive({ + selector: '[contenteditableModel]' +}) +export class ContenteditableModelDirective implements OnChanges { + + @Input('contenteditableModel') + public model: any; + + @Output('contenteditableModelChange') + public update = new EventEmitter(); + + private _lastViewModel: any; + + constructor(private elRef: ElementRef) {} + + public ngOnChanges(changes: SimpleChanges): void { + if(this._lastViewModel !== changes['model'].currentValue){ + this._lastViewModel = this.model; + this._refreshView(); + } + } + + @HostListener('blur') + public onBlur() { + if(this.elRef.nativeElement.type == 'checkbox' || this.elRef.nativeElement.type == 'radio'){ + var value = this.elRef.nativeElement.checked; + this._lastViewModel = value; + this.update.emit(value); + } + else{ + var value = this.elRef.nativeElement.innerText; + this._lastViewModel = value; + this.update.emit(value); + } + } + + private _refreshView() { + if(this.elRef.nativeElement.type == 'checkbox' || this.elRef.nativeElement.type == 'radio'){ + this.elRef.nativeElement.value = this.model; + this.elRef.nativeElement.checked = this.model; + } + else{ + this.elRef.nativeElement.innerText = this.model; + } + } +} \ No newline at end of file