Пример #1
0
        public KeyValuePair <int, String> CallWrapUpCategory_ChangeStatus(CallWrapUpCategory model)
        {
            var param = new SqlParameter[] {
                new SqlParameter("@CallWrapUpCategoryID", SqlDbType.UniqueIdentifier)
                {
                    Value = model.CallWrapUpCategoryID
                },
                new SqlParameter("@ModifiedBy", SqlDbType.UniqueIdentifier)
                {
                    Value = model.ModifiedBy
                },
                new SqlParameter("@RetVal", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@Message", SqlDbType.NVarChar, 100)
                {
                    Direction = ParameterDirection.Output
                }
            };

            int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [CRM].[CallWrapUpCategory_ChangeStatus] @CallWrapUpCategoryID, @ModifiedBy, @RetVal out, @Message out", param);

            int    retVal   = (int)param[2].Value;
            string valueRes = param[3].Value.ToString();

            return(new KeyValuePair <int, string>(retVal, valueRes));
        }
Пример #2
0
        public KeyValuePair <int, String> CallWrapUpCategory_Insert(CallWrapUpCategory model, SessionForSP sessionParam)
        {
            var param = new SqlParameter[] {
                new SqlParameter("@CallWrapUpCategoryID", SqlDbType.UniqueIdentifier)
                {
                    Value = model.CallWrapUpCategoryID
                },
                new SqlParameter("@Description", SqlDbType.NVarChar, 200)
                {
                    Value = CheckForDbNull(model.Description)
                },
                new SqlParameter("@ModifiedBy", SqlDbType.UniqueIdentifier)
                {
                    Value = model.ModifiedBy
                },
                new SqlParameter("@OrganizationID", sessionParam.OrganizationID),
                new SqlParameter("@RetVal", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@Message", SqlDbType.NVarChar, 100)
                {
                    Direction = ParameterDirection.Output
                }
            };

            int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [CRM].[CallWrapUpCategory_Insert] @CallWrapUpCategoryID, @Description, @ModifiedBy, @OrganizationID, @RetVal out, @Message out", param);

            int    retVal   = (int)param[4].Value;
            string valueRes = param[5].Value.ToString();

            return(new KeyValuePair <int, string>(retVal, valueRes));
        }
        public ActionResult formSubmit(CallWrapUpCategory model, string actionType)
        {
            List <string> errorMessage   = new List <string>();
            string        successMessage = Resources.NotifResource.RequestSuccess;
            SessionForSP  sessionParam   = new SessionForSP();

            sessionParam.OrganizationID = new Guid(Session["OrganizationID"].ToString());

            if (ModelState.IsValid)
            {
                KeyValuePair <int, string> results = new KeyValuePair <int, string>(1, "");
                model.ModifiedBy = new Guid(Session["CurrentUserID"].ToString());
                if (actionType == "Create")
                {
                    model.CallWrapUpCategoryID = Guid.NewGuid();
                    results = db.CallWrapUpCategory_Insert(model, sessionParam);
                }
                else if (actionType == "Edit")
                {
                    results = db.CallWrapUpCategory_Update(model);
                }
                else if (actionType == "ChangeStatus")
                {
                    results = db.CallWrapUpCategory_ChangeStatus(model);
                }
                else if (actionType == "Delete")
                {
                    results = db.CallWrapUpCategory_Delete(model);
                }

                if (results.Key == 0 || results.Key == 16 || results.Key == 6)
                {
                    UrlHelper u      = new UrlHelper(this.ControllerContext.RequestContext);
                    string    url    = u.Action("Edit", "CallWrapUpCategory", new { id = model.CallWrapUpCategoryID, success = successMessage });
                    string    urlNew = u.Action("Create", "CallWrapUpCategory");

                    var jsonData = new { flag = true, Message = url, urlNew = urlNew };
                    return(Json(jsonData));
                }
                else
                {
                    var jsonData = new { flag = false, Message = results.Value.ToString() };
                    return(Json(jsonData));
                }
            }
            else
            {
                foreach (var key in ModelState.Keys)
                {
                    var error = ModelState[key].Errors.FirstOrDefault();
                    if (error != null)
                    {
                        errorMessage.Add(error.ErrorMessage);
                    }
                }
                var jsonData = new { flag = false, Message = errorMessage.First() };
                return(Json(jsonData));
            }
        }
 public ActionResult Delete(CallWrapUpCategory model)
 {
     return(formSubmit(model, "Delete"));
 }
 public ActionResult ChangeStatus(CallWrapUpCategory model)
 {
     return(formSubmit(model, "ChangeStatus"));
 }
 public ActionResult Edit(CallWrapUpCategory model)
 {
     return(formSubmit(model, "Edit"));
 }
        public ActionResult Edit(Guid id)
        {
            CallWrapUpCategory model = db.callWrapUpCategory.Find(id);

            return(View(model));
        }
        public ActionResult Create()
        {
            CallWrapUpCategory cwu = new CallWrapUpCategory();

            return(View(cwu));
        }