Ejemplo n.º 1
0
        public async Task <ApiResultCode> UserRegisterAsync(Tblclient datamodel)
        {
            _ = _unit.GetRepository <Tblclient>().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"));
        }
Ejemplo n.º 2
0
        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 <ApiResultCode> FranchiseeUpdateItSelfAsync(Tblclient datamodel)
        {
            if (datamodel.Tbluser != null)
            {
                _unit.Context.Tblclient.Attach(datamodel);
                _unit.Context.Entry(datamodel).Property(t => t.CompanyPanCardNo).IsModified = true;
                _unit.Context.Entry(datamodel).Property(t => t.CompanyGstNo).IsModified     = true;
                _unit.Context.Entry(datamodel).Property(t => t.FullAddress).IsModified      = true;
                _unit.Context.Entry(datamodel).Property(t => t.Name).IsModified             = true;
                _unit.Context.Entry(datamodel).Property(t => t.PhoneNo).IsModified          = true;
                _unit.Context.Entry(datamodel).Property(t => t.Email).IsModified            = true;
                _unit.Context.Entry(datamodel).Property(t => t.CityLocationid).IsModified   = true;
                _unit.Context.Entry(datamodel).Property(t => t.ZipCode).IsModified          = true;
                _unit.Context.Entry(datamodel).Property(t => t.UpdatedDate).IsModified      = true;

                foreach (var client in datamodel.Tbluser)
                {
                    _unit.Context.Tbluser.Attach(client);
                    _unit.Context.Entry(client).Property(t => t.FirstName).IsModified      = true;
                    _unit.Context.Entry(client).Property(t => t.MiddleName).IsModified     = true;
                    _unit.Context.Entry(client).Property(t => t.LastName).IsModified       = true;
                    _unit.Context.Entry(client).Property(t => t.LastUpdateDate).IsModified = true;
                    foreach (var item in client.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.OwnerPancardNo).IsModified     = true;
                            _unit.Context.Entry(item).Property(t => t.OwnersAadharCardNo).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;
            }
            if (datamodel.Tblfeedetail.Count > 0)
            {
                foreach (var item in datamodel.Tblfeedetail)
                {
                    if (item.Id > 0)
                    {
                        _unit.Context.Tblfeedetail.Attach(item);
                        _unit.Context.Entry(item).Property(t => t.FeeValue).IsModified       = true;
                        _unit.Context.Entry(item).Property(t => t.TotalFee).IsModified       = true;
                        _unit.Context.Entry(item).Property(t => t.PaymentTerms).IsModified   = true;
                        _unit.Context.Entry(item).Property(t => t.PaymentDueDate).IsModified = true;
                        _unit.Context.Entry(item).Property(t => t.Updatedate).IsModified     = true;
                        _unit.Context.Entry(item).Property(t => t.UpdatedBy).IsModified      = true;
                    }
                    else
                    {
                        _unit.Context.Tblfeedetail.Add(item);
                    }
                }
            }
            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 async Task <IActionResult> Handle(FranchiseeItSelfRegistrationCommand request, CancellationToken cancellationToken)
        {
            Tblclient clientobj = new Tblclient();
            var       _response = new Response();

            try
            {
                clientobj.Name         = request.CompanyName;
                clientobj.InsertedDate = DateTime.Now;
                clientobj.Status       = 1;
                clientobj.UpdatedDate  = DateTime.Now;
                //clientobj.CityLocationid = request.CityId;
                clientobj.ZipCode = request.Pincode;
                var data = _mapper.Map <Tbluser>(request);
                data.IsGuestUser    = 0;
                data.PasswordHash   = Utilities.Utility.EncryptionLibrary.EncryptText(data.PasswordHash);
                data.Status         = 1;
                data.InsertDate     = DateTime.Now;
                data.LastUpdateDate = DateTime.Now;
                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());
                }
                data.UserTypeId = request.UserTypeId;
                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
                });
                data.Tbluserrolemapping.Add(new Tbluserrolemapping
                {
                    RoleId = 2
                });
                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
                        });
                    }
                }
                clientobj.Tbluser.Add(data);
                var result = await _account.UserRegisterAsync(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());
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ProviderLayer, ex);
                _response.Status  = false;
                _response.Message = "Exception";
                return(_response.ToHttpResponse());
            }
        }
Ejemplo n.º 5
0
        public async Task <ApiResult <CompanyDetailQueryModel> > AddNewFranchiseeByCompany(Tblclient datamodel)
        {
            _ = _unit.GetRepository <Tblclient>().Add(datamodel);
            var result = await _unit.SaveChangesAsync();

            if (result.ResultType == ApiResultType.Success)
            {
                long userid     = datamodel.Tbluser.Select(t => t.Id).FirstOrDefault();
                var  resultdata = await this.GetUserDetailByUserIdAsync(userid);

                if (resultdata.HasSuccess)
                {
                    return(new ApiResult <CompanyDetailQueryModel>(new ApiResultCode(ApiResultType.Success, messageText: "Register Successfully"), resultdata.UserObject));
                }
            }
            return(new ApiResult <CompanyDetailQueryModel>(new ApiResultCode(ApiResultType.Error, messageText: "Error during create")));
        }
        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());
            }
        }