public object UpdateSection(SectionParam objParam)
        {
            Tbl_Section_Master obj = db.Tbl_Section_Master.SingleOrDefault(r => r.SectionId == objParam.Sectionid);

            obj.SectionName  = objParam.SectionName;
            obj.ModifiedBy   = 1;
            obj.ModifiedDate = DateTime.Now;
            db.SaveChanges();
            return(new Result()
            {
                IsSucess = true, ResultData = "Record Updated Successfully"
            });
        }
        public object SaveSection(SectionParam objParam)
        {
            Tbl_Section_Master obj = new Tbl_Section_Master();

            obj.SectionName  = objParam.SectionName;
            obj.Status       = 1;
            obj.CreatedBy    = 1;
            obj.CreatedDate  = DateTime.Now;
            obj.ModifiedBy   = null;
            obj.ModifiedDate = null;
            db.Tbl_Section_Master.Add(obj);
            db.SaveChanges();
            return(new Result()
            {
                IsSucess = true, ResultData = "Section Save Successfully"
            });
        }
Beispiel #3
0
        public object UpdateSection(SectionParam objParam)
        {
            var Data = db.Tbl_Section_Master.Where(r => r.SectionName == objParam.SectionName).FirstOrDefault();

            if (Data == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Duplicate Entry Not Allowed"
                });
            }
            Tbl_Section_Master obj = db.Tbl_Section_Master.SingleOrDefault(r => r.SectionId == objParam.Sectionid);

            obj.SectionName  = objParam.SectionName;
            obj.ModifiedBy   = 1;
            obj.ModifiedDate = DateTime.Now;
            db.SaveChanges();
            return(new Result()
            {
                IsSucess = true, ResultData = "Record Updated Successfully"
            });
        }
 public object DeleteSection(SectionParam objParam)
 {
     if (objParam.Status == 1)
     {
         Tbl_Section_Master obj = db.Tbl_Section_Master.SingleOrDefault(r => r.SectionId == objParam.Sectionid && r.Status == 1);
         obj.Status = 0;
         db.SaveChanges();
         return(new Result()
         {
             IsSucess = true, ResultData = "Record Deactivated Successfully"
         });
     }
     else
     {
         Tbl_Section_Master obj = db.Tbl_Section_Master.SingleOrDefault(r => r.SectionId == objParam.Sectionid && r.Status == 0);
         obj.Status = 1;
         db.SaveChanges();
         return(new Result()
         {
             IsSucess = true, ResultData = "Record Activated Successfully"
         });
     }
 }