public JsonResult UpdateType(CreateMembershipTypeModel model)
        {
            // Check double name
            if (model.Name != model.NameCurrent)
            {
                if (_membershipService.ExistMembershipType(model) > 0)
                {
                    return Json(-4);
                }
            }

            var result = _membershipService.UpdateMembershipType(model);
            return result ? Json(1) : Json(-100);
        }
 public int ExistMembershipType(CreateMembershipTypeModel model)
 {
     using (var sql = GetSqlConnection())
     {
         var data = sql.Query<int>("ExistMembershipType", new { name = model.Name }, commandType: CommandType.StoredProcedure);
         sql.Close();
         return data.FirstOrDefault();
     }
 }
        public ActionResult Type(CreateMembershipTypeModel model)
        {
            // Check double name
            if (_membershipService.ExistMembershipType(model) > 0)
            {
                return Json(-4);
            }

            _membershipService.InsertMembershipType(model);
            return !ModelState.IsValid ? Json(-100) : Json(1);
        }
 public bool UpdateMembershipType(CreateMembershipTypeModel model)
 {
     using (var sql = GetSqlConnection())
     {
         var data = sql.Query<bool>("UpdateMembershipType", new { id = model.Id, name = model.Name, top = model.Top, premium = model.Premium, express = model.Express, duration = model.Duration, price = model.Price, userCreated = model.LastUserUpdated }, commandType: CommandType.StoredProcedure);
         sql.Close();
         return data.FirstOrDefault();
     }
 }