Esempio n. 1
0
 public JsonResult remove(int id = 0)
 {
     try
     {
         RDClientChannel model = db.RDClientChannels.Find(id);
         if (model != null)
         {
             BoolString validation = model.BeforeDelete(db);
             if (validation.BoolValue)
             {
                 return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet));
             }
             db.RDClientChannels.Remove(model);
             db.SaveChanges();
             validation = model.AfterDelete(db);
             if (validation.BoolValue)
             {
                 return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet));
             }
             return(Json(new { id = model.id, MessageSucess = "That Client Channel deleted successfully." }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { Message = "This record no longer exists" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "Client Channel") }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 2
0
        public JsonResult get(string id)
        {
            RDClientChannel model = db.RDClientChannels.Find(id);

            if (model != null)
            {
                return(Json(model, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Message = "This record no longer exists" }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 3
0
 public JsonResult ToggleActive(string id = "")
 {
     try
     {
         RDClientChannel model = db.RDClientChannels.Find(Guid.Parse(id.Replace("─", "-")));
         if (model != null)
         {
             if (model.active.Value)
             {
                 BoolString validation = model.BeforeInactive(db);
                 if (validation.BoolValue)
                 {
                     return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet));
                 }
                 model.active = !model.active;
                 db.SaveChanges();
                 validation = model.AfterInactive(db);
                 if (validation.BoolValue)
                 {
                     return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet));
                 }
                 return(Json(new { id = model.id, MessageSucess = "That Client Channel Inactive successfully." }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 BoolString validation = model.BeforeActive(db);
                 if (validation.BoolValue)
                 {
                     return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet));
                 }
                 model.active = !model.active;
                 db.SaveChanges();
                 validation = model.AfterActive(db);
                 if (validation.BoolValue)
                 {
                     return(Json(new { Message = validation.StringValue }, JsonRequestBehavior.AllowGet));
                 }
                 return(Json(new { id = model.id, MessageSucess = "That Client Channel Active successfully." }, JsonRequestBehavior.AllowGet));
             }
         }
         return(Json(new { Message = "This record no longer exists" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "Client Channel") }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 4
0
        public JsonResult update(int id, RDClientChannel model)
        {
            BoolString validation = model.BeforeEdit(db);

            if (validation.BoolValue)
            {
                return(Json(new { Message = validation.StringValue }));
            }
            db.Entry(model).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            validation = model.AfterEdit(db);
            if (validation.BoolValue)
            {
                return(Json(new { Message = validation.StringValue }));
            }
            return(Json(new { id = model.id, MessageSucess = "That Client Channel saved successfully." }));
        }
Esempio n. 5
0
        public JsonResult create(RDClientChannel model)
        {
            BoolString validation = model.BeforeSave(db);

            if (validation.BoolValue)
            {
                return(Json(new { Message = validation.StringValue }));
            }
            db.RDClientChannels.Add(model);
            db.SaveChanges();
            validation = model.AfterSave(db);
            if (validation.BoolValue)
            {
                return(Json(new { Message = validation.StringValue }));
            }
            return(Json(new { id = model.id, MessageSucess = "That Client Channel saved successfully." }));
        }
Esempio n. 6
0
 public ActionResult Form(string id = "", string from = "")
 {
     ViewBag.relations = db.VWISRElations.Where(d => d.PK_Table == "RDClientChannel").ToList();
     ViewBag.from      = from;
     if (id == "")
     {
         return(PartialView(new RDClientChannel()
         {
             active = true, creationDate = DateTime.Now
         }));
     }
     else
     {
         RDClientChannel model = db.RDClientChannels.Find(Guid.Parse(id.Replace("─", "-")));
         return(PartialView(model));
     }
 }
Esempio n. 7
0
        public JsonResult Save(RDClientChannel model, FormCollection form)
        {
            try
            {
                model.id = form["id"].ToString() == "00000000-0000-0000-0000-000000000000" ? new Guid() : Guid.Parse(form["id"].ToString().Replace("─", "-"));
                if (model.id != new Guid())
                {
                    BoolString validation = model.BeforeEdit(db);
                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                    validation            = model.BeforeSave(db);
                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                    validation = model.BeforeEdit(db);

                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                    db.SaveChanges();
                    validation = model.AfterSave(db);

                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                    validation = model.AfterEdit(db);

                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                }
                else
                {
                    model.id = Guid.NewGuid();
                    BoolString validation = model.BeforeSave(db);
                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                    validation = model.BeforeCreate(db);
                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }

                    db.RDClientChannels.Add(model);
                    db.SaveChanges();
                    validation = model.AfterSave(db);
                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                    validation = model.AfterCreate(db);
                    if (validation.BoolValue)
                    {
                        return(Json(new { Message = validation.StringValue }));
                    }
                }
                return(Json(new { id = model.id, MessageSucess = "That Client Channel saved successfully." }));
            }
            catch (Exception ex)
            {
                return(Json(new { Message = Helper.ModeralException(ex).Replace("@table", "Client Channel") }));
            }
        }