[Authorize(Roles = "Administrator")]//Save Entry
 public JsonResult SaveEntry(ENT.CountryMasterSUB model, string CountryID)
 {
     try
     {
         List <Guid> dctDuplication = new List <Guid>();
         if (model.EntryMode == COM.MyEnumration.EntryMode.ADD)
         {
             model.Status = COM.MyEnumration.MyStatus.Active;
             List <ENT.CountryMasterSUB> lstResult = new BAL.CountryMasterBAL().CheckDuplicateCombination(dctDuplication, COM.MyEnumration.MasterType.MainDeviceMaster, model.CountryName);
             if (lstResult.Count > 0)
             {
                 throw new Exception("Country Name Already Exists.");
             }
             if (objBAL.Insert(model))
             {
                 GlobalVarible.AddMessage("Record Save Successfully");
             }
         }
         else
         {
             model.CreatedDateTime = DateTime.Now;
             model.CountryID       = new Guid(CountryID.Replace("/", ""));
             if (objBAL.Update(model))
             {
                 GlobalVarible.AddMessage("Record Update Successfully");
             }
         }
     }
     catch (Exception ex)
     { GlobalVarible.AddError(ex.Message); }
     MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
     return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
 }
        [Authorize(Roles = "Administrator")]//Update Status
        public JsonResult UpdateStatus(string id)
        {
            GlobalVarible.Clear();
            try
            {
                if (id != null)
                {
                    Model           = new Josheph.Framework.Entity.CountryMasterSUB();
                    Model.CountryID = new Guid(id);
                    Model           = (ENT.CountryMasterSUB)objBAL.GetByPrimaryKey(Model);
                    if (Model.Status == COM.MyEnumration.MyStatus.Active)
                    {
                        if (!objBAL.UpdateStatus(Model.CountryID, COM.MyEnumration.MyStatus.DeActive))
                        {
                            throw new Exception("Internal Server Error in status update.");
                        }
                    }

                    if (Model.Status == COM.MyEnumration.MyStatus.DeActive)
                    {
                        if (!objBAL.UpdateStatus(Model.CountryID, COM.MyEnumration.MyStatus.Active))
                        {
                            throw new Exception("Internal Server Error in status update.");
                        }
                    }
                    GlobalVarible.AddMessage("Status Update Successfully.");
                }
            }
            catch (Exception ex)
            { GlobalVarible.AddError(ex.Message); }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
 private List <string> ValidationEntry(object obj)
 {
     strvalidationResult.Clear();
     Entity = (ENT.CountryMasterSUB)obj;
     if (string.IsNullOrWhiteSpace(Entity.CountryName))
     {
         strvalidationResult.Add("Country Name Required!");
     }
     return(strvalidationResult);
 }
 [Authorize(Roles = "Administrator")]//Edit Record
 public JsonResult EditRecord(string id)
 {
     if (id != null)
     {
         Model = new Josheph.Framework.Entity.CountryMasterSUB();
         Model.UpdatedDateTime = DateTime.Now;
         Model.CountryID       = new Guid(id);
         Model = (ENT.CountryMasterSUB)objBAL.GetByPrimaryKey(Model);
     }
     return(Json(new { Model = Model }, JsonRequestBehavior.AllowGet));
 }
Beispiel #5
0
        public object GetByPrimaryKey(ENT.CountryMasterSUB Entity)
        {
            object objResult = null;

            try
            {
                DAL.CRUDOperation tt = new DAL.CRUDOperation();
                objResult = tt.GetEntityByPrimartKey(Entity);
            }
            catch (Exception) { throw; }
            return(objResult);
        }
 [Authorize(Roles = "Administrator")]//Delete Entry
 public JsonResult DeleteEntry(string id)
 {
     GlobalVarible.Clear();
     if (id != null)
     {
         Model           = new Josheph.Framework.Entity.CountryMasterSUB();
         Model.CountryID = new Guid(id);
         if (objBAL.Delete(Model))
         {
             GlobalVarible.AddMessage("Record Delete Successfully.");
         }
         else
         {
             GlobalVarible.AddError("Internal Server Error Please Try Again");
         }
     }
     MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
     return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
 }