Example #1
0
        public async Task <ActionResult> UpdateAcount(CustomerAppIG4Item data)
        {
            var customer = _agencyDa.GetById(CustomerId);

            if (customer == null)
            {
                return(Json(new JsonMessage(1000, "Not found")));
            }

            if (!string.IsNullOrEmpty(data.Mobile) && customerDA.CheckExitsByPhone(CustomerId, data.Mobile))
            {
                return(Json(new JsonMessage(1000, "Số điện thoại đã tồn tại")));
            }

            if (!string.IsNullOrEmpty(data.Email) && customerDA.CheckExitsByEmail(CustomerId, data.Email))
            {
                return(Json(new JsonMessage(1000, "Email đã tồn tại")));
            }
            customer.Email = data.Email;
            //customer.Description = data.Description;
            customer.FullName = data.Fullname;
            customer.Address  = data.Address;
            //customer.Mobile = data.Mobile;

            var file = Request.Files["fileAvatar"];

            if (file != null)
            {
                var img = await UploadImage(file);

                if (img.Code != 200)
                {
                    return(Json(new JsonMessage(1000, "Tải Avatar không thành công")));
                }
                customer.AvatarUrl = img.Data.Folder + img.Data.Url;
            }
            file = Request.Files["fileImgTimeline"];
            if (file != null)
            {
                var img = await UploadImage(file);

                if (img.Code != 200)
                {
                    return(Json(new JsonMessage(1000, "Tải ảnh bìa không thành công")));
                }
                customer.ImageTimeline = img.Data.Folder + img.Data.Url;
            }
            customerDA.Save();
            var obj = _agencyDa.GetItemByIdApp(CustomerId);

            return(Json(new BaseResponse <CustomerAppIG4Item> {
                Code = 200, Data = obj
            }, JsonRequestBehavior.AllowGet));
        }