예제 #1
0
 public long UpdateStoreAddress(StoreAddressObject city)
 {
     try
     {
         if (city == null)
         {
             return(-2);
         }
         var duplicates = _repository.Count(m => m.StreetNo.Trim().ToLower().Equals(city.StreetNo.Trim().ToLower()) && city.StoreCityId.Equals(m.StoreCityId) && (m.StoreAddressId != city.StoreAddressId));
         if (duplicates > 0)
         {
             var ads = _repository.GetAll(m => m.StreetNo.Trim().ToLower().Equals(city.StreetNo.Trim().ToLower()) && city.StoreCityId.Equals(m.StoreCityId)).ToList();
             if (ads.Any())
             {
                 return(ads[0].StoreAddressId);
             }
         }
         var cityEntity = ModelCrossMapper.Map <StoreAddressObject, StoreAddress>(city);
         if (cityEntity == null || cityEntity.StoreAddressId < 1)
         {
             return(-2);
         }
         _repository.Update(cityEntity);
         _uoWork.SaveChanges();
         return(5);
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
예제 #2
0
        private GenericValidator ValidateStoreAddress(StoreAddressObject storeAddress)
        {
            var gVal = new GenericValidator();

            if (storeAddress == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }
            if (string.IsNullOrEmpty(storeAddress.StreetNo))
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Store_Address_StreetNo_Error;
                return(gVal);
            }

            if (storeAddress.StoreCityId < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.City_Selection_Error;
                return(gVal);
            }

            gVal.Code = 5;
            return(gVal);
        }
예제 #3
0
        public ActionResult EditStoreAddress(StoreAddressObject storeAddress)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreAddress(storeAddress);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = 0;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_storeAddress"] == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldStoreAddress = Session["_storeAddress"] as StoreAddressObject;
                    if (oldStoreAddress == null || oldStoreAddress.StoreAddressId < 1)
                    {
                        gVal.Code  = -5;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldStoreAddress.StreetNo    = storeAddress.StreetNo.Trim();
                    oldStoreAddress.StoreCityId = storeAddress.StoreCityId;
                    var k = new StoreAddressServices().UpdateStoreAddress(oldStoreAddress);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Update_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
예제 #4
0
        public ActionResult AddStoreOutlet(StoreOutletObject storeOutlet)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreOutlet(storeOutlet);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var storeAddress = new StoreAddressObject
                    {
                        StoreCityId = storeOutlet.StoreAddressObject.StoreCityId,
                        StreetNo    = storeOutlet.StoreAddressObject.StreetNo
                    };
                    var t = new StoreAddressServices().AddStoreAddress(storeAddress);
                    if (t < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Outlet_Address_Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    storeOutlet.StoreAddressId = t;
                    storeOutlet.DateCreated    = DateTime.Now;
                    var k = new StoreOutletServices().AddStoreOutlet(storeOutlet);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = -1;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Insertion_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 0;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
 public long UpdateStoreAddress(StoreAddressObject city)
 {
     try
     {
         return(_cityRepository.UpdateStoreAddress(city));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(-2);
     }
 }
예제 #6
0
 public long AddStoreAddress(StoreAddressObject storeAddress)
 {
     try
     {
         return(_cityRepository.AddStoreAddress(storeAddress));
     }
     catch (Exception ex)
     {
         ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
예제 #7
0
        public long AddStoreAddress(StoreAddressObject city)
        {
            try
            {
                if (city == null)
                {
                    return(-2);
                }
                var duplicates = _repository.Count(m => m.StreetNo.Trim().ToLower().Equals(city.StreetNo.Trim().ToLower()) && city.StoreCityId.Equals(m.StoreCityId));
                if (duplicates > 0)
                {
                    var ads = _repository.GetAll(m => m.StreetNo.Trim().ToLower().Equals(city.StreetNo.Trim().ToLower()) && city.StoreCityId.Equals(m.StoreCityId)).ToList();
                    if (ads.Any())
                    {
                        return(ads[0].StoreAddressId);
                    }
                }
                var cityEntity = ModelCrossMapper.Map <StoreAddressObject, StoreAddress>(city);
                if (cityEntity == null || string.IsNullOrEmpty(cityEntity.StreetNo))
                {
                    return(-2);
                }
                var returnStatus = _repository.Add(cityEntity);
                _uoWork.SaveChanges();
                return(returnStatus.StoreAddressId);
            }

            catch (DbEntityValidationException e)
            {
                var str = "";
                foreach (var eve in e.EntityValidationErrors)
                {
                    str += string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                         eve.Entry.Entity.GetType().Name, eve.Entry.State) + "\n";
                    foreach (var ve in eve.ValidationErrors)
                    {
                        str += string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                             ve.PropertyName, ve.ErrorMessage) + " \n";
                    }
                }
                ErrorLogger.LogError(e.StackTrace, e.Source, str);
                return(0);
            }
        }
예제 #8
0
        public ActionResult AddStoreAddress(StoreAddressObject storeAddress)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreAddress(storeAddress);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = 0;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var k = new StoreAddressServices().AddStoreAddress(storeAddress);
                    if (k < 1)
                    {
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        gVal.Code  = 0;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = k;
                    gVal.Error = message_Feedback.Insertion_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
예제 #9
0
        public async Task <ActionResult> EditProfile(EmployeeObject employee)
        {
            var gVal = new GenericValidator();

            try
            {
                var valStatus = ValidateProfile(employee);
                if (valStatus.Code < 1)
                {
                    gVal.Code  = 0;
                    gVal.Error = valStatus.Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_employee"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Session_Time_Out;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldEmployee = Session["_employee"] as EmployeeObject;
                if (oldEmployee == null || oldEmployee.EmployeeId < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Session_Time_Out;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var user = UserManager.FindByEmail(employee.Email);
                if (user == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "User information could not be updated.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (!string.IsNullOrEmpty(employee.Password))
                {
                    if (string.IsNullOrEmpty(employee.OriginalPassword))
                    {
                        gVal.Code  = -1;
                        gVal.Error = "Please provide your original password.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (string.IsNullOrEmpty(employee.ConfirmPassword))
                    {
                        gVal.Code  = -1;
                        gVal.Error = "Please provide your password password confirmation.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (employee.Password != employee.ConfirmPassword)
                    {
                        gVal.Code  = -1;
                        gVal.Error = "The passwords do not match";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var passwordResult = UserManager.CheckPassword(user, employee.OriginalPassword);
                    if (!passwordResult)
                    {
                        gVal.Code  = -1;
                        gVal.Error = "Your original password could not be verified.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var passwordHash = new PasswordHasher().HashPassword(employee.Password);
                    user.PasswordHash = passwordHash;
                    var result = await UserManager.UpdateAsync(user);

                    if (!result.Succeeded)
                    {
                        gVal.Code  = -1;
                        gVal.Error = "User information could not be updated.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.PasswordUpdated = true;
                }

                var address = new StoreAddressObject
                {
                    StreetNo       = employee.StreetNo,
                    StoreAddressId = employee.StoreAddressId,
                    StoreCityId    = employee.StoreCityId
                };

                var ad = new StoreAddressServices().UpdateStoreAddress(address);
                if (ad < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Employee_Address_Update_Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                oldEmployee.Email          = employee.Email;
                oldEmployee.PhoneNumber    = employee.PhoneNumber;
                oldEmployee.OtherNames     = employee.OtherNames;
                oldEmployee.LastName       = employee.LastName;
                oldEmployee.EmployeeNo     = employee.EmployeeNo;
                oldEmployee.Birthday       = employee.Birthday;
                oldEmployee.StoreAddressId = employee.StoreAddressId;
                oldEmployee.Birthday       = employee.Birthday;

                var k = new EmployeeServices().UpdateEmployeeProfile(oldEmployee);
                if (k < 1)
                {
                    gVal.Error = k == -3 ? "A different user with similar phone number already exists!" : message_Feedback.Update_Failure;
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = "Your profile was successfully updated.";
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
예제 #10
0
        public async Task <ActionResult> EditEmployee(EmployeeObject employee, string subdomain)
        {
            var storeSetting = new SessionHelpers().GetStoreInfo(subdomain);

            if (storeSetting == null || storeSetting.StoreId < 1)
            {
                return(Json(new CustomerObject(), JsonRequestBehavior.AllowGet));
            }
            var gVal = new GenericValidator();

            try
            {
                var valStatus = ValidateEmployee(employee);
                if (valStatus.Code < 1)
                {
                    gVal.Code  = 0;
                    gVal.Error = valStatus.Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (Session["_employee"] == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Session_Time_Out;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var oldEmployee = Session["_employee"] as EmployeeObject;
                if (oldEmployee == null || oldEmployee.EmployeeId < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Session_Time_Out;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var user = UserManager.FindByEmail(employee.Email);
                if (user == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "User information could not be updated.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }


                var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext(storeSetting.EntityConnectionString)));
                var role        = roleManager.FindById(employee.RoleId);
                if (role == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "User information could not be updated.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var userRoles = UserManager.GetRoles(oldEmployee.AspNetUserId).ToList();
                if (!userRoles.Any())
                {
                    return(Json(new EmployeeObject(), JsonRequestBehavior.AllowGet));
                }

                if (!string.IsNullOrEmpty(employee.Password))
                {
                    var passwordHash = new PasswordHasher().HashPassword(employee.Password);
                    user.PasswordHash = passwordHash;
                    var result = await UserManager.UpdateAsync(user);

                    if (!result.Succeeded)
                    {
                        gVal.Code  = -1;
                        gVal.Error = "User information could not be updated.";
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                }

                var address = new StoreAddressObject
                {
                    StreetNo       = employee.StreetNo,
                    StoreAddressId = employee.StoreAddressId,
                    StoreCityId    = employee.StoreCityId
                };

                var ad = new StoreAddressServices().UpdateStoreAddress(address);
                if (ad < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Employee_Address_Update_Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                oldEmployee.Email             = employee.Email;
                oldEmployee.PhoneNumber       = employee.PhoneNumber;
                oldEmployee.OtherNames        = employee.OtherNames;
                oldEmployee.LastName          = employee.LastName;
                oldEmployee.Status            = employee.Status;
                oldEmployee.EmployeeNo        = employee.EmployeeNo;
                oldEmployee.RoleId            = employee.RoleId;
                oldEmployee.DateHired         = employee.DateHired;
                oldEmployee.DateLeft          = employee.DateLeft;
                oldEmployee.StoreOutletId     = employee.StoreOutletId;
                oldEmployee.StoreAddressId    = employee.StoreAddressId;
                oldEmployee.StoreDepartmentId = employee.StoreDepartmentId;


                var k = new EmployeeServices().UpdateEmployee(oldEmployee);
                if (k < 1)
                {
                    gVal.Error = k == -3 ? "A different user with similar phone number already exists!" : message_Feedback.Update_Failure;
                    gVal.Code  = 0;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var userRole = userRoles[0];

                if (role.Name.ToLower() != userRole.ToLower())
                {
                    UserManager.RemoveFromRole(oldEmployee.AspNetUserId, userRole);
                    UserManager.AddToRole(oldEmployee.AspNetUserId, role.Name);
                }

                gVal.Code  = 5;
                gVal.Error = message_Feedback.Update_Success;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
예제 #11
0
        public async Task <ActionResult> AddEmployee(EmployeeObject employee, string subdomain)
        {
            var storeSetting = new SessionHelpers().GetStoreInfo(subdomain);

            if (storeSetting == null || storeSetting.StoreId < 1)
            {
                return(Json(new CustomerObject(), JsonRequestBehavior.AllowGet));
            }

            var gVal = new GenericValidator();

            try
            {
                var valStatus = ValidateEmployee(employee);
                if (valStatus.Code < 1)
                {
                    gVal.Code  = 0;
                    gVal.Error = valStatus.Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                if (string.IsNullOrEmpty(employee.Password))
                {
                    gVal.Code  = -1;
                    gVal.Error = "ERROR: Please Provide Password.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var checkDuplicatePhoneNumber = new EmployeeServices().VerifyPhoneNumber(employee.PhoneNumber);
                if (checkDuplicatePhoneNumber)
                {
                    gVal.Code  = -1;
                    gVal.Error = "A user with the same phone number already exists.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var address = new StoreAddressObject
                {
                    StreetNo    = employee.StreetNo,
                    StoreCityId = employee.StoreCityId
                };

                var ad = new StoreAddressServices().AddStoreAddress(address);
                if (ad < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Employee_Address_Add_Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                UserManager.UserLockoutEnabledByDefault = false;
                var status = (int)EmployeeStatus.Active;
                var user   = new ApplicationUser
                {
                    UserName    = employee.Email,
                    Email       = employee.Email,
                    PhoneNumber = employee.PhoneNumber,
                    UserInfo    = new ApplicationDbContext.UserProfile
                    {
                        LastName     = employee.LastName,
                        OtherNames   = employee.OtherNames,
                        IsActive     = employee.Status == status,
                        MobileNumber = employee.PhoneNumber,
                        ContactEmail = employee.Email
                    }
                };

                var result = await UserManager.CreateAsync(user, employee.Password);

                if (!result.Succeeded)
                {
                    gVal.Code  = -1;
                    gVal.Error = result.Errors.ToList()[0];
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext(storeSetting.EntityConnectionString)));
                var role        = roleManager.FindById(employee.RoleId);
                if (role == null)
                {
                    gVal.Code  = -1;
                    gVal.Error = "User information could not be updated.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                UserManager.AddToRole(user.Id, role.Name);

                //todo: change to dynamic outletid
                employee.StoreAddressId = ad;
                //employee.StoreOutletId = 1;

                var employeeNo = GenerateEmpoyeeNo();

                if (string.IsNullOrEmpty(employeeNo))
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Process_Failed;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                employee.EmployeeNo = employeeNo;
                employee.UserId     = user.UserInfo.Id;
                var k = new EmployeeServices().AddEmployee(employee);
                if (k < 1)
                {
                    gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                    gVal.Code  = 0;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                gVal.Code  = k;
                gVal.Error = message_Feedback.Insertion_Success;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
예제 #12
0
        public ActionResult EditStoreOutlet(StoreOutletObject storeOutlet)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateStoreOutlet(storeOutlet);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_storeOutlet"] == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldStoreOutlet = Session["_storeOutlet"] as StoreOutletObject;
                    if (oldStoreOutlet == null || oldStoreOutlet.StoreOutletId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreOutlet.OutletName     = storeOutlet.OutletName;
                    oldStoreOutlet.DefaultTax     = storeOutlet.DefaultTax;
                    oldStoreOutlet.FacebookHandle = storeOutlet.FacebookHandle;

                    var storeAddress = new StoreAddressObject
                    {
                        StoreCityId    = storeOutlet.StoreAddressObject.StoreCityId,
                        StreetNo       = storeOutlet.StoreAddressObject.StreetNo,
                        StoreAddressId = oldStoreOutlet.StoreAddressId
                    };

                    var t = new StoreAddressServices().UpdateStoreAddress(storeAddress);
                    if (t < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Outlet_Address_Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    oldStoreOutlet.IsOperational = storeOutlet.IsOperational;
                    if (!string.IsNullOrEmpty(oldStoreOutlet.FacebookHandle))
                    {
                        oldStoreOutlet.FacebookHandle = storeOutlet.FacebookHandle;
                    }

                    if (!string.IsNullOrEmpty(oldStoreOutlet.TwitterHandle))
                    {
                        oldStoreOutlet.TwitterHandle = storeOutlet.TwitterHandle;
                    }

                    var k = new StoreOutletServices().UpdateStoreOutlet(oldStoreOutlet);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Update_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }