public string UpdatePreferences(PreferenceVM preference)
        {
            string preferenceId = string.Empty;

            SqlParameter[] parameters =
            {
                new SqlParameter {
                    ParameterName = "@Id", Value = preference.Id
                },
                new SqlParameter {
                    ParameterName = "@PreferenceGroupId", Value = preference.PreferenceGroupId
                },
                new SqlParameter {
                    ParameterName = "@Code", Value = preference.Code
                },
                new SqlParameter {
                    ParameterName = "@Description", Value = preference.Description
                },
                new SqlParameter {
                    ParameterName = "@IsActive", Value = preference.IsActive
                },
                new SqlParameter {
                    ParameterName = "@UpdatedBy", Value = preference.UpdatedBy
                }
            };

            preferenceId = Convert.ToString(DALHelper.ExecuteScalar("UpdatePreferences", parameters));

            return(preferenceId);
        }
        public ActionResult Create(PreferenceVM model)
        {
            try
            {
                string preferenceId = string.Empty;

                model.CreatedBy = LogInManager.LoggedInUserId;
                preferenceId    = preferenceRepository.AddPreferences(model);

                if (!string.IsNullOrWhiteSpace(preferenceId))
                {
                    return(Json(new
                    {
                        IsSuccess = true,
                        data = new
                        {
                            PreferenceId = preferenceId
                        }
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Preference not saved successfully."
                    }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "Create");
                return(Json(new { IsSuccess = false, errorMessage = e.Message }));
            }
        }
        public ActionResult Create()
        {
            var preferenceGroupList = new SelectList(preferenceGroupRepository.GetPreferenceGroup(), "Id", "Name").ToList();

            PreferenceVM model = new PreferenceVM();

            model.IsActive = true;

            ViewBag.PreferenceGroupList = preferenceGroupList;

            return(View(model));
        }
        public ActionResult Edit(Guid id)
        {
            var preference = preferenceRepository.GetPreferenceById(id);

            PreferenceVM model = new PreferenceVM();

            if (preference != null && preference.Count > 0)
            {
                model = preference[0];

                var preferenceGroupList = new SelectList(preferenceGroupRepository.GetPreferenceGroup(), "Id", "Name").ToList();

                ViewBag.PreferenceGroupList = preferenceGroupList;

                return(View(model));
            }

            return(RedirectToAction("List"));
        }