public async Task <IActionResult> Handle(LOIDocumentUploadCommand request, CancellationToken cancellationToken) { var _response = new SingleResponse <UplodLoiDocFileResponse>(); if (request.LoiDocFile != null) { string strDirectory = "\\LOIDocumnetUpload" + "\\" + Regex.Replace(request.FranchiseeId.ToString(), @"\s+", ""); Tbluserdoument documentdata = new Tbluserdoument(); var fileResult = WriteFile(request.LoiDocFile, strDirectory, "").Result; if (request.DocumentId > 0) { documentdata.Id = request.DocumentId; } if (fileResult.HasSuccess) { documentdata.DocImagePath = fileResult.UserObject.ImagePath; } documentdata.UserId = request.FranchiseeId; documentdata.InsertedBy = request.CurrentUserId; documentdata.DocumentTypeId = 6; documentdata.UserTypeId = request.CurrentUserTypeId; documentdata.Remark = request.LoiDocFile.FileName; documentdata.InsertDate = DateTime.Now; documentdata.LastUpdateDate = DateTime.Now; documentdata.Status = 1; try { var result = await _account.FranchiseeLoiUpload(documentdata); if (result.HasSuccess) { _response.Status = true; _response.Message = result.ResultCode.MessageText; _response.Data = result.UserObject; return(_response.ToHttpResponse()); } else { _response.Status = false; _response.Message = result.ResultCode.MessageText; return(_response.ToHttpResponse()); } } catch (Exception ex) { ErrorTrace.Logger(LogArea.ProviderLayer, ex); _response.Status = false; _response.Message = "Exception"; } return(_response.ToHttpResponse()); } _response.Status = false; _response.Message = "Please upload file"; return(_response.ToHttpResponse()); }
public async Task <ApiResult <UplodLoiDocFileResponse> > FranchiseeLoiUpload(Tbluserdoument datamodel) { UplodLoiDocFileResponse uplodLoi = new UplodLoiDocFileResponse(); uplodLoi.FileName = datamodel.Remark; if (datamodel.Id > 0) { _ = _unit.Context.Tbluserdoument.Attach(datamodel); _unit.Context.Entry(datamodel).Property(t => t.DocImagePath).IsModified = true; } else { _ = _unit.GetRepository <Tbluserdoument>().Add(datamodel); } var result = await _unit.SaveChangesAsync(); if (result.ResultType == ApiResultType.Success) { return(new ApiResult <UplodLoiDocFileResponse>(new ApiResultCode(ApiResultType.Success, messageText: "File uploaded Successfully"), uplodLoi)); } return(new ApiResult <UplodLoiDocFileResponse>(new ApiResultCode(ApiResultType.Error, messageText: "Error during Update"))); }
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(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()); } }