Example #1
0
        public async Task UpdateNaqelUserRegistrationDetails(NaqelUsersDto NaqelUsersDto)
        {
            int naqelUsersId      = (int)NaqelUsersDto.Id;
            var NaqelUsersDetails = Repository.SingleOrDefault(x => x.Id == naqelUsersId);

            if (!string.IsNullOrEmpty(NaqelUsersDto.FirstName))
            {
                NaqelUsersDetails.FirstName = NaqelUsersDto.FirstName;
            }
            if (!string.IsNullOrEmpty(NaqelUsersDto.LastName))
            {
                NaqelUsersDetails.LastName = NaqelUsersDto.LastName;
            }
            if (!string.IsNullOrEmpty(NaqelUsersDto.Mobile))
            {
                NaqelUsersDetails.Mobile = NaqelUsersDto.Mobile;
            }
            if (!string.IsNullOrEmpty(NaqelUsersDto.Address))
            {
                NaqelUsersDetails.Address = NaqelUsersDto.Address;
            }
            if (!string.IsNullOrEmpty(NaqelUsersDto.Country))
            {
                NaqelUsersDetails.Country = Convert.ToInt32(NaqelUsersDto.Country);
            }
            //if (!string.IsNullOrEmpty(NaqelUsersDto.Image))
            //{
            NaqelUsersDetails.Image = NaqelUsersDto.Image;
            //}
            await Repository.UpdateAsync(NaqelUsersDetails);
        }
Example #2
0
        public async Task <NaqelUsers> GetNaqelUserDetails(NaqelUsersDto NaqelUsersDto)
        {
            var isvalid = Repository.SingleOrDefault(x => x.Email == NaqelUsersDto.Email);

            if (isvalid == null)
            {
                return(null);
            }
            return(isvalid);
        }
        public async Task <IActionResult> updateNaqelUser(NaqelUsersDto NaqelUsersDto)
        {
            try
            {
                Guid strMerchantImagesID = Guid.NewGuid();
                strMerchantImages = _configuration["FilePath:ImagePath"] + "NaqelUsersImages/";
                if (!String.IsNullOrEmpty(NaqelUsersDto.Image))
                {
                    if (NaqelUsersDto.Image.Substring(NaqelUsersDto.Image.Length - 3) != "jpg")
                    {
                        if (!String.IsNullOrEmpty(NaqelUsersDto.Image))
                        {
                            if (!Directory.Exists(strMerchantImages))
                            {
                                Directory.CreateDirectory(strMerchantImages);
                            }
                            Byte[] imageByteData = Convert.FromBase64String(NaqelUsersDto.Image);
                            var    fs            = new BinaryWriter(new FileStream(strMerchantImages + strMerchantImagesID + ".jpg", FileMode.Create, FileAccess.Write));
                            fs.Write(imageByteData);
                            fs.Close();
                            NaqelUsersDto.Image = strMerchantImagesID + ".jpg";
                        }
                    }
                    else
                    {
                        NaqelUsersDto.Image = Path.GetFileName(NaqelUsersDto.Image);
                    }
                }
                else
                {
                    NaqelUsersDto.Image = "";
                }

                await _naqelUsersService.UpdateNaqelUserRegistrationDetails(NaqelUsersDto);

                return(Ok(new GenericResultDto <string> {
                    Result = "NaqelUser updated successfully", ReFirstName = NaqelUsersDto.FirstName, ReEmail = NaqelUsersDto.Email
                }));
            }

            catch (Exception err)
            {
                return(BadRequest(new GenericResultDto <string> {
                    Result = err.Message
                }));
            }
        }