public object CREATETIMETABLE(TimeTableParam tobj) { TimetableBusiness ObjTerm = new TimetableBusiness(); var GetTermVar = ObjTerm.ADDTABLE(tobj); return(GetTermVar); }
public object ADDTABLE(TimeTableParam tobj) { try { SchoolMainContext db = new ConcreateContext().GetContext(tobj.UserName, tobj.Password); if (db == null) { return(new Results() { IsSuccess = false, Message = "Invalid User" }); } var Info = db.TBLUSERLOGINs.Where(r => r.UserName == tobj.UserName && r.Password == tobj.Password).FirstOrDefault(); if (Info == null) { return(new Results() { IsSuccess = false, Message = "Invalid User" }); } int EmployeeID = Convert.ToInt16(Info.EmpCode); TBLTIMETABLESCHEDULE data = db.TBLTIMETABLESCHEDULEs.Where(r => r.DISPLAY == 1 && r.EMPLOYEEID == EmployeeID && r.BATCHID == tobj.BATCHID && r.WORKINGDAYS == tobj.WORKINGDAYS).FirstOrDefault(); if (data != null) { return(new Results() { IsSuccess = false, Message = "Already Time Table Created" }); } else { var AcademicYear = db.View_GETACADEMICYEAR.FirstOrDefault(); TBLTIMETABLESCHEDULE obj = new TBLTIMETABLESCHEDULE(); obj.EMPLOYEEID = EmployeeID; obj.STANDARDID = tobj.STANDARDID; obj.SUBJECTID = tobj.SUBJECTID; obj.BATCHID = tobj.BATCHID; obj.WORKINGDAYS = tobj.WORKINGDAYS; obj.EDUYEAR = AcademicYear.ACADEMICYEAR; obj.DISPLAY = 1; obj.COMPANYID = 1; obj.CREATEDID = 1; obj.UPDATEDID = 1; obj.CREATEDON = System.DateTime.Now.Date; obj.UPDATEDON = System.DateTime.Now.Date; obj.TIMETABLENAME = tobj.TIMETABLENAME; obj.CLASSROOMID = tobj.CLASSROOMID; obj.DIVISION = tobj.DIVISION; obj.ROOMTYPE = tobj.ROOMTYPE; obj.LABBATCH = tobj.LABBATCH; db.TBLTIMETABLESCHEDULEs.Add(obj); db.SaveChanges(); } return(new Results() { IsSuccess = true, Message = "Created Timetable" }); } catch (Exception ex) { var st = new StackTrace(ex, true); return(new Results { IsSuccess = false, Message = ex.Message }); } }
public object ADDTABLE(TimeTableParam tobj) { try { SchoolMainContext db = new ConcreateContext().GetContext(tobj.Userid, tobj.Password); if (db == null) { return(new Results() { IsSuccess = false, Message = "Invalid User" }); } TBLTIMETABLESCHEDULE data = db.TBLTIMETABLESCHEDULEs.Where(r => r.DISPLAY == 1 && r.EMPLOYEEID == tobj.EMPLOYEEID).FirstOrDefault(); if (data != null) { var info = db.TBLTIMETABLESCHEDULEs.Where(r => r.DISPLAY == 1 && r.BATCHID == tobj.BATCHID).FirstOrDefault(); if (info != null) { return(new Results() { IsSuccess = false, Message = "Already Time Table Created" }); } else { TBLTIMETABLESCHEDULE obj = new TBLTIMETABLESCHEDULE(); obj.EMPLOYEEID = tobj.EMPLOYEEID; obj.STANDARDID = tobj.STANDARDID; obj.SUBJECTID = tobj.SUBJECTID; obj.BATCHID = tobj.BATCHID; obj.WORKINGDAYS = tobj.WORKINGDAYS; obj.EDUYEAR = tobj.EDUYEAR; obj.DISPLAY = 1; obj.COMPANYID = 1; obj.CREATEDID = 1; obj.UPDATEDID = 1; obj.CREATEDON = System.DateTime.Now.Date; obj.UPDATEDON = System.DateTime.Now.Date; obj.TIMETABLENAME = tobj.TIMETABLENAME; obj.CLASSROOMID = tobj.CLASSROOMID; obj.DIVISION = tobj.DIVISION; obj.ROOMTYPE = tobj.ROOMTYPE; obj.LABBATCH = tobj.LABBATCH; db.TBLTIMETABLESCHEDULEs.Add(obj); db.SaveChanges(); } } return(new Results() { IsSuccess = true, Message = "Created Timetable" }); } catch (Exception ex) { var st = new StackTrace(ex, true); return(new Results { IsSuccess = false, Message = ex.Message }); } }