public object AddAcademic([FromBody] AcademicParam obj)
 {
     try
     {
         AcademicYearBussiness save = new AcademicYearBussiness();
         var result = save.SaveAcademic(obj);
         return(result);
     }
     catch (Exception e)
     {
         return(new Error()
         {
             IsError = true, Message = e.Message
         });
     }
 }
Esempio n. 2
0
        public object SaveAcademic(AcademicParam b)
        {
            if (b.Type == null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Required Type"
                });
            }
            var data = db.Tbl_AcademicYear_Master.FirstOrDefault(r => r.Type == b.Type && r.Status == 0);

            if (data != null)
            {
                return(new Error()
                {
                    IsError = true, Message = "Duplicate Entry Not Allowed"
                });
            }
            try
            {
                Tbl_AcademicYear_Master obj = new Tbl_AcademicYear_Master();
                obj.Type         = b.Type;
                obj.AcademicYear = b.AcademicYear;
                obj.StartDate    = Convert.ToDateTime(b.StartDate.ToShortDateString());
                obj.EndDate      = Convert.ToDateTime(b.EndDate.ToShortDateString());
                obj.Status       = 1;
                obj.CreatedBy    = 1;
                obj.CreatedDate  = System.DateTime.Today.Date;
                obj.ModifiedBy   = null;
                obj.ModifiedDate = System.DateTime.Today.Date;
                db.Tbl_AcademicYear_Master.Add(obj);
                db.SaveChanges();
                return(new Result()
                {
                    IsSucess = true, ResultData = "Created Academic Year"
                });
            }
            catch (Exception e)
            {
                return(new Error()
                {
                    IsError = true, Message = e.Message
                });
            }
        }