public IHttpActionResult PutTbladdress(int id, Tbladdress tbladdress)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbladdress.addressID)
            {
                return(BadRequest());
            }

            db.Entry(tbladdress).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TbladdressExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostTbladdress(Tbladdress tbladdress)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Tbladdresses.Add(tbladdress);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tbladdress.addressID }, tbladdress));
        }
        public IHttpActionResult DeleteTbladdress(int id)
        {
            Tbladdress tbladdress = db.Tbladdresses.Find(id);

            if (tbladdress == null)
            {
                return(NotFound());
            }

            db.Tbladdresses.Remove(tbladdress);
            db.SaveChanges();

            return(Ok(tbladdress));
        }
示例#4
0
        public async Task <ApiResultCode> UserAddressUpdateAsync(Tbladdress datamodel)
        {
            _unit.Context.Tbladdress.Attach(datamodel);
            _unit.Context.Entry(datamodel).Property(t => t.FullAddress).IsModified    = true;
            _unit.Context.Entry(datamodel).Property(t => t.StateId).IsModified        = true;
            _unit.Context.Entry(datamodel).Property(t => t.CityId).IsModified         = true;
            _unit.Context.Entry(datamodel).Property(t => t.CityLocationId).IsModified = true;
            _unit.Context.Entry(datamodel).Property(t => t.LandMark).IsModified       = true;
            _unit.Context.Entry(datamodel).Property(t => t.LastUpdateDate).IsModified = true;
            _unit.Context.Entry(datamodel).Property(t => t.LastUpdatedBy).IsModified  = true;
            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"));
        }
示例#5
0
        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());
            }
        }