public async Task <ApiResultCode> AllocateSuperviser(AllocateEmployeeCommand datamodel) { var tbluser = new Tbluser(); tbluser.Id = datamodel.UserId; tbluser.ContactPersonId = datamodel.EmployeeId; tbluser.LastUpdatedBy = datamodel.CurrentUserId; tbluser.LastUpdateDate = DateTime.Now; _unit.Context.Tbluser.Attach(tbluser); _unit.Context.Entry(tbluser).Property(t => t.ContactPersonId).IsModified = true; //_unit.Context.Entry(tbluser).Property(t => t.IsApproved).IsModified = true; _unit.Context.Entry(tbluser).Property(t => t.LastUpdatedBy).IsModified = true; _unit.Context.Entry(tbluser).Property(t => t.LastUpdateDate).IsModified = true; var result = await _unit.SaveChangesAsync(); if (result.ResultType == ApiResultType.Success) { return(new ApiResultCode(ApiResultType.Success, messageText: "Update Successfully")); } else { return(new ApiResultCode(ApiResultType.Error, messageText: "Error during update")); } }
public async Task <ApiResultCode> CreateUserByFranchiseeAsync(Tbluser datamodel) { _ = _unit.GetRepository <Tbluser>().Add(datamodel); var result = await _unit.SaveChangesAsync(); if (result.ResultType == ApiResultType.Success) { return(new ApiResultCode(ApiResultType.Success, messageText: "Register Successfully")); } return(new ApiResultCode(ApiResultType.Error, messageText: "Error during create")); }
public async Task <ApiResultCode> UserUpdateAsync(Tbluser datamodel) { _unit.Context.Tbluser.Attach(datamodel); _unit.Context.Entry(datamodel).Property(t => t.FirstName).IsModified = true; _unit.Context.Entry(datamodel).Property(t => t.MiddleName).IsModified = true; _unit.Context.Entry(datamodel).Property(t => t.LastName).IsModified = true; _unit.Context.Entry(datamodel).Property(t => t.LastUpdateDate).IsModified = true; _unit.Context.Entry(datamodel).Property(t => t.PhoneNumber).IsModified = true; foreach (var item in datamodel.Tbluserdetail) { if (item.Id > 0) { _unit.Context.Tbluserdetail.Attach(item); _unit.Context.Entry(item).Property(t => t.AlternateNumber).IsModified = true; _unit.Context.Entry(item).Property(t => t.AlternateEmail).IsModified = true; _unit.Context.Entry(item).Property(t => t.LastUpdateDate).IsModified = true; } } foreach (var item in datamodel.Tbluserdoument) { if (item.Id > 0) { _unit.Context.Tbluserdoument.Attach(item); _unit.Context.Entry(item).Property(t => t.DocImagePath).IsModified = true; _unit.Context.Entry(item).Property(t => t.DocumentTypeId).IsModified = true; _unit.Context.Entry(item).Property(t => t.Remark).IsModified = true; _unit.Context.Entry(item).Property(t => t.LastUpdateDate).IsModified = true; } else { _unit.Context.Tbluserdoument.Add(item); } item.Status = 1; item.InsertDate = DateTime.Now; item.LastUpdateDate = DateTime.Now; item.DocumentTypeId = item.DocumentTypeId; item.Remark = item.Remark; } var result = await _unit.SaveChangesAsync(); if (result.ResultType == ApiResultType.Success) { return(new ApiResultCode(ApiResultType.Success, messageText: "Updated Successfully")); } return(new ApiResultCode(ApiResultType.Error, messageText: "Error during Update")); }
public ActionResult Login(Tbluser user) { if (ModelState.IsValid) { var a = context.Tblusers.Where(i => i.Username.Equals(user.Username) && i.Password.Equals(user.Password)).FirstOrDefault(); if (a != null) { Session["loginId"] = a.Id.ToString(); return(RedirectToAction("Addproduct", "Account")); } else { ViewBag.message = "Username and Password is Incorrect"; ModelState.AddModelError("", "Username and Password is Incorrect"); } } return(View()); }
public async Task <ApiResult <FranchiseeApprovalResonse> > FranchiseeApproveAsync(ClientApproveCommand datamodel) { var tbluser = new Tbluser(); tbluser.Id = datamodel.Id; if (datamodel.IsApproved == true) { tbluser.IsApproved = 1; } if (datamodel.IsApproved == false) { tbluser.IsApproved = 0; } tbluser.LastUpdatedBy = datamodel.CurrentUserId; tbluser.LastUpdateDate = DateTime.Now; _unit.Context.Tbluser.Attach(tbluser); _unit.Context.Entry(tbluser).Property(t => t.IsApproved).IsModified = true; _unit.Context.Entry(tbluser).Property(t => t.LastUpdatedBy).IsModified = true; _unit.Context.Entry(tbluser).Property(t => t.LastUpdateDate).IsModified = true; var result = await _unit.SaveChangesAsync(); if (result.ResultType == ApiResultType.Success) { FranchiseeApprovalResonse resonse = new FranchiseeApprovalResonse(); if (datamodel.IsApproved == true) { resonse.ApproveStatus = "Approve"; } if (datamodel.IsApproved == false) { resonse.ApproveStatus = "Disapprove "; } return(new ApiResult <FranchiseeApprovalResonse>(new ApiResultCode(ApiResultType.Success, messageText: "Update Successfully"), resonse)); } return(new ApiResult <FranchiseeApprovalResonse>(new ApiResultCode(ApiResultType.Error, messageText: "Error during create"))); }
public async Task <IActionResult> Handle(AddNewFranchiseeUserCommand request, CancellationToken cancellationToken) { Tblclient clientobj = new Tblclient(); var _response = new SingleResponse <CompanyDetailQueryModel>(); try { if (_account.IsEmailExist(request.Email).Result.UserObject) { _response.Status = false; _response.Message = "Email already in use."; _response.ErrorTypeCode = (int)ErrorMessage.Email; return(_response.ToHttpResponse()); } if (_account.IsPhoneExist(request.PhoneNumber).Result.UserObject) { _response.Status = false; _response.Message = "Phone no. already in use."; _response.ErrorTypeCode = (int)ErrorMessage.Phone; return(_response.ToHttpResponse()); } clientobj.Name = request.CompanyName; clientobj.InsertedDate = DateTime.Now; clientobj.Status = 1; clientobj.UpdatedDate = DateTime.Now; clientobj.CityLocationid = request.CityLocationId <= 0 ? request.Address.CityLocationId : request.CityLocationId; clientobj.Email = request.CompanyEmail; clientobj.PhoneNo = request.CompanyPhone; clientobj.FullAddress = request.CompanyAddress; clientobj.ZipCode = request.Pincode; var data = new Tbluser(); data.FirstName = request.FirstName; data.MiddleName = request.MiddleName; data.LastName = request.LastName; data.Email = request.Email; data.PhoneNumber = request.PhoneNumber; data.UserTypeId = request.UserTypeId; data.PasswordHash = request.PasswordHash; data.IsGuestUser = 0; data.PasswordHash = Utilities.Utility.EncryptionLibrary.EncryptText(data.PasswordHash); data.Status = 1; data.InsertDate = DateTime.Now; data.LastUpdateDate = DateTime.Now; data.UserTypeId = request.UserTypeId; var tblfeedetail = new List <Tblfeedetail>(); if (request.FranchiseeFee != null) { tblfeedetail.Add(new Tblfeedetail { FeeValue = Convert.ToDecimal(request.FranchiseeFee.FranchiseeFee), FeeTypeId = request.FranchiseeFee.FranchiseeFeeId, TotalFee = request.FranchiseeFee.TotalAmmount, PaidAmmout = Convert.ToDecimal(request.FranchiseeFee.FranchiseeFeePaidAmout), PaymentTerms = request.FranchiseeFee.PaymentTerms, PaymentDueDate = !string.IsNullOrEmpty(request.FranchiseeFee.PaymentDueDate) ? DateTime.ParseExact(request.FranchiseeFee.PaymentDueDate, "dd/MM/yyyy", null) : default }); tblfeedetail.Add(new Tblfeedetail { FeeValue = Convert.ToDecimal(request.FranchiseeFee.OtherFee), FeeTypeId = request.FranchiseeFee.OtherFeeId, TotalFee = request.FranchiseeFee.TotalAmmount, PaidAmmout = Convert.ToDecimal(request.FranchiseeFee.OtherFeePaidAmout), PaymentTerms = request.FranchiseeFee.PaymentTerms, PaymentDueDate = !string.IsNullOrEmpty(request.FranchiseeFee.PaymentDueDate) ? DateTime.ParseExact(request.FranchiseeFee.PaymentDueDate, "dd/MM/yyyy", null) : default });
public async Task <IActionResult> Handle(UpdateUserCommand request, CancellationToken cancellationToken) { var _response = new Response(); Tbluser data = null; List <Tbluserdoument> docdto = new List <Tbluserdoument>(); try { string strDirectory = string.Empty; if (!string.IsNullOrEmpty(request.FirstName) && (request.CurrentUserId.HasValue && request.CurrentUserId > 0)) { strDirectory = "\\" + Regex.Replace(request.CurrentUserId.ToString(), @"\s+", "") + "\\" + Regex.Replace(request.FirstName.ToString(), @"\s+", ""); } if (request.CurrentUserId.HasValue) { data = new Tbluser(); data.FirstName = request.FirstName; data.MiddleName = request.MiddleName; data.LastName = request.LastName; data.Email = request.Email; data.PhoneNumber = request.PhoneNumber; data.Id = request.UserId > 0 ? request.UserId : request.CurrentUserId.Value; data.LastUpdateDate = DateTime.Now; data.Tbluserdetail.Add(new Tbluserdetail { Id = request.UserDetail.Id, AlternateNumber = request.UserDetail.AlternateNumber, AlternateEmail = request.UserDetail.AlternateEmail }); Tbluserdoument documentdata = null; if (request.UserDocumentCommands.Any(t => t.DocFile != null)) { foreach (var item in request.UserDocumentCommands) { documentdata = new Tbluserdoument(); if (item.DocFile != null) { var fileResult = WriteFile(item.DocFile, strDirectory, "").Result; if (item.Id > 0) { documentdata.Id = item.Id; documentdata.LastUpdateDate = DateTime.Now; documentdata.LastUpdatedBy = request.CurrentUserId; documentdata.DocumentTypeId = item.DocumentType; documentdata.UserTypeId = CurrentUserTypeId; } else { documentdata.UserTypeId = CurrentUserTypeId; documentdata.Remark = item.Remark; documentdata.InsertedBy = request.CurrentUserId; documentdata.InsertDate = DateTime.Now; documentdata.DocumentTypeId = item.DocumentType; documentdata.Status = 1; } if (fileResult.HasSuccess) { documentdata.DocImagePath = fileResult.UserObject.ImagePath; } docdto.Add(documentdata); } } } if (request.LoiFile != null) { documentdata = new Tbluserdoument(); strDirectory = "\\" + Regex.Replace(request.CurrentUserId.ToString(), @"\s+", "") + "\\" + Regex.Replace(request.FirstName.ToString(), @"\s+", "" + "\\Loidocument"); var fileResult = WriteFile(request.LoiFile, strDirectory, ""); documentdata.UserTypeId = CurrentUserTypeId; documentdata.InsertedBy = request.CurrentUserId; documentdata.InsertDate = DateTime.Now; documentdata.DocumentTypeId = 4; documentdata.Status = 1; docdto.Add(documentdata); } if (request.Address != null) { if (request.Address.AddressId > 0) { var address = new Tbladdress { Id = request.Address.AddressId, FullAddress = request.Address.FullAdrrss, LandMark = request.Address.LandMark, ZipCode = request.Address.ZipCode, CountryId = 101, CityLocationId = request.Address.CityLocationId, LastUpdatedBy = request.CurrentUserId, LastUpdateDate = DateTime.Now }; var updateaddressresult = await _account.UserAddressUpdateAsync(address); } else { data.Tbluseraddressmapping.Add(new Tbluseraddressmapping { Address = new Tbladdress { Id = request.Address.AddressId, FullAddress = request.Address.FullAdrrss, LandMark = request.Address.LandMark, ZipCode = request.Address.ZipCode, CountryId = 101, CityLocationId = request.Address.CityLocationId, InsertedBy = request.CurrentUserId, InsertDate = DateTime.Now }, UserId = request.CurrentUserId }); } } data.Tbluserdoument = docdto; var result = await _account.UserUpdateAsync(data); if (result.ResultType == ApiResultType.Success) { _response.Status = true; _response.Message = result.MessageText; return(_response.ToHttpResponse()); } else { _response.Status = false; _response.Message = result.MessageText; return(_response.ToHttpResponse()); } } return(_response.ToHttpResponse()); } catch (Exception ex) { ErrorTrace.Logger(LogArea.ProviderLayer, ex); _response.Status = false; _response.Message = "Exception"; return(_response.ToHttpResponse()); } }
public async Task <IActionResult> Handle(CreateNewUserCommand request, CancellationToken cancellationToken) { var _response = new Response(); try { if (_account.IsEmailExist(request.Email).Result.UserObject) { _response.Status = false; _response.Message = "Email already in use."; _response.ErrorTypeCode = (int)ErrorMessage.Email; return(_response.ToHttpResponse()); } if (_account.IsPhoneExist(request.PhoneNumber).Result.UserObject) { _response.Status = false; _response.Message = "Phone no. already in use."; _response.ErrorTypeCode = (int)ErrorMessage.Phone; return(_response.ToHttpResponse()); } var data = new Tbluser(); data.FirstName = request.FirstName; data.MiddleName = request.MiddleName; data.LastName = request.LastName; data.Email = request.Email; data.PhoneNumber = request.PhoneNumber; if (request.UserType == 3) { data.IsApproved = 1; } data.UserTypeId = request.UserType; data.ClientId = request.CurrentCientId; data.PasswordHash = request.PasswordHash; data.IsGuestUser = 0; data.PasswordHash = Utilities.Utility.EncryptionLibrary.EncryptText(data.PasswordHash); data.Status = 1; data.InsertDate = DateTime.Now; data.LastUpdateDate = DateTime.Now; data.UserTypeId = request.UserType; data.InsertedBy = request.CurrentUserId; data.Tbluserdetail.Add(new Tbluserdetail { FullName = string.Format("{0} {1} {2}", data.FirstName, data.MiddleName, data.LastName), Status = 1, InsertDate = DateTime.Now, LastUpdateDate = DateTime.Now, InsertedBy = data.Id, LastUpdatedBy = data.Id, AlternateEmail = request.AlternateEmail, AlternateNumber = request.AlternatePhone }); data.Tbluserrolemapping.Add(new Tbluserrolemapping { RoleId = 4 }); if (request.Address != null) { if (request.Address.CityLocationId > 0) { data.Tbluseraddressmapping.Add(new Tbluseraddressmapping { Address = new Tbladdress { FullAddress = request.Address.FullAdrrss, LandMark = request.Address.LandMark, ZipCode = request.Address.ZipCode, CountryId = 101, CityLocationId = request.Address.CityLocationId, InsertedBy = request.CurrentUserId, InsertDate = DateTime.Now }, UserId = data.Id }); } } var result = await _account.CreateUserByFranchiseeAsync(data); if (result.ResultType == ApiResultType.Success) { _response.Status = true; _response.Message = result.MessageText; return(_response.ToHttpResponse()); } else { _response.Status = false; _response.Message = result.MessageText; return(_response.ToHttpResponse()); } } catch (Exception ex) { ErrorTrace.Logger(LogArea.ProviderLayer, ex); _response.Status = false; _response.Message = "Exception"; return(_response.ToHttpResponse()); } }
public async Task <IActionResult> Handle(FranchiseeItSelfProfileUpdateCommand request, CancellationToken cancellationToken) { var _response = new Response(); Tblclient clientobj = new Tblclient(); Tbluser data = null; List <Tbluserdoument> docdto = new List <Tbluserdoument>(); try { string strDirectory = string.Empty; if (!string.IsNullOrEmpty(request.FirstName) && (request.CurrentUserId.HasValue && request.CurrentUserId > 0)) { strDirectory = "\\" + Regex.Replace(request.CurrentUserId.ToString(), @"\s+", "") + "\\" + Regex.Replace(request.FirstName.ToString(), @"\s+", ""); } clientobj.Id = request.CompanyId > 0 ? request.CompanyId : request.CurrentCientId; clientobj.Name = request.CompayName; clientobj.InsertedDate = DateTime.Now; clientobj.Status = 1; clientobj.UpdatedDate = DateTime.Now; clientobj.FullAddress = request.CompanyAddress; clientobj.CityLocationid = request.CompanyAddressCity; clientobj.ZipCode = request.CompanyPincode; clientobj.CompanyPanCardNo = request.CompanyPANCardNo; clientobj.CompanyGstNo = request.CompanyGSTNo; clientobj.Email = request.CompayEmail; clientobj.PhoneNo = request.CompayPhone; if (request.CurrentUserId.HasValue) { data = new Tbluser(); data.FirstName = request.FirstName; data.MiddleName = request.MiddleName; data.LastName = request.LastName; //data.Email = request.Email; data.PhoneNumber = request.PhoneNumber; data.Id = request.UserId > 0 ? request.UserId : request.CurrentUserId.Value; data.LastUpdateDate = DateTime.Now; data.Tbluserdetail.Add(new Tbluserdetail { Id = request.UserDetail.Id, AlternateNumber = request.UserDetail.AlternateNumber, AlternateEmail = request.UserDetail.AlternateEmail, OwnersAadharCardNo = request.UserDetail.OwnersAadharCardNo, OwnerPancardNo = request.UserDetail.OwnerPANCardNo, }); Tbluserdoument documentdata = null; if (request.UserDocumentCommands.Any(t => t.DocFile != null)) { foreach (var item in request.UserDocumentCommands) { documentdata = new Tbluserdoument(); if (item.DocFile != null) { var fileResult = WriteFile(item.DocFile, strDirectory, "").Result; FileInfo fi = new FileInfo(item.DocFile.FileName); if (item.Id > 0) { documentdata.Id = item.Id; documentdata.LastUpdateDate = DateTime.Now; documentdata.Remark = fi.Name; documentdata.LastUpdatedBy = request.CurrentUserId; documentdata.DocumentTypeId = item.DocumentType; documentdata.UserTypeId = request.CurrentUserTypeId; } else { documentdata.UserId = request.CurrentUserId; documentdata.UserTypeId = request.CurrentUserTypeId; documentdata.Remark = fi.Name; documentdata.InsertedBy = request.CurrentUserId; documentdata.InsertDate = DateTime.Now; documentdata.DocumentTypeId = item.DocumentType; documentdata.Status = 1; } if (fileResult.HasSuccess) { documentdata.DocImagePath = fileResult.UserObject.ImagePath; } docdto.Add(documentdata); } } } if (request.LoiFile != null) { documentdata = new Tbluserdoument(); strDirectory = "\\" + Regex.Replace(request.CurrentUserId.ToString(), @"\s+", "") + "\\" + Regex.Replace(request.FirstName.ToString(), @"\s+", "" + "\\Loidocument"); var fileResult = WriteFile(request.LoiFile, strDirectory, ""); documentdata.UserTypeId = CurrentUserTypeId; documentdata.InsertedBy = request.CurrentUserId; documentdata.InsertDate = DateTime.Now; documentdata.DocumentTypeId = 4; documentdata.Status = 1; docdto.Add(documentdata); } if (request.Address != null) { if (request.Address.AddressId > 0) { var address = new Tbladdress { Id = request.Address.AddressId, FullAddress = request.Address.FullAdrrss, LandMark = request.Address.LandMark, ZipCode = request.Address.ZipCode, CountryId = 101, CityLocationId = request.Address.CityLocationId, LastUpdatedBy = request.CurrentUserId, LastUpdateDate = DateTime.Now }; var updateaddressresult = await _account.UserAddressUpdateAsync(address); } else { data.Tbluseraddressmapping.Add(new Tbluseraddressmapping { Address = new Tbladdress { FullAddress = request.Address.FullAdrrss, LandMark = request.Address.LandMark, ZipCode = request.Address.ZipCode, CountryId = 101, CityLocationId = request.Address.CityLocationId, InsertedBy = request.CurrentUserId, InsertDate = DateTime.Now }, UserId = request.CurrentUserId }); } } List <Tblfeedetail> tblfeedetails = new List <Tblfeedetail>(); Tblfeedetail tblfeedetail = null; if (request.FranchiseeFeeCommands.Count > 0) { foreach (var item in request.FranchiseeFeeCommands) { tblfeedetail = new Tblfeedetail { Id = item.FeeId, ClientId = request.CompanyId, UserId = request.UserId, FeeValue = Convert.ToDecimal(item.FeeValue), FeeTypeId = item.FeeTypeId, TotalFee = item.TotalFee, PaymentTerms = item.PaymentTerms, UpdatedBy = request.CurrentUserId, PaymentDueDate = !string.IsNullOrEmpty(item.PaymentDueDate) ? DateTime.ParseExact(item.PaymentDueDate, "dd/MM/yyyy", null) : default }; tblfeedetails.Add(tblfeedetail); } } clientobj.Tbluser.Add(data); clientobj.Tbluserdoument = docdto; clientobj.Tblfeedetail = tblfeedetails; var result = await _franchisee.FranchiseeUpdateItSelfAsync(clientobj); if (result.ResultType == ApiResultType.Success) { _response.Status = true; _response.Message = result.MessageText; return(_response.ToHttpResponse()); } else { _response.Status = false; _response.Message = result.MessageText; return(_response.ToHttpResponse()); } } return(_response.ToHttpResponse()); } catch (Exception ex) { ErrorTrace.Logger(LogArea.ProviderLayer, ex); _response.Status = false; _response.Message = "Exception"; return(_response.ToHttpResponse()); } }