public object EventUpdate(EventMasterUpdateParam b) { if (b.EventTypeID == 0) { return(new Error() { IsError = true, Message = "Required Event Type" }); } var data = db.Tbl_EventMaster.Where(r => r.EventID == b.EventID).FirstOrDefault(); try { Tbl_EventMaster obj = new Tbl_EventMaster(); data.EventID = b.EventID; data.EventName = b.EventName; data.StartDate = b.StartDate; data.EndDate = b.EndDate; data.ModifiedBy = null; data.ModifiedDate = System.DateTime.Today.Date; db.SaveChanges(); return(new Result() { IsSucess = true, ResultData = "Update Event" }); } catch (Exception e) { return(new Error() { IsError = true, Message = e.Message }); } }
public object DeleteEvent(EventMasterUpdateParam PM) { try { Tbl_EventMaster obj = db.Tbl_EventMaster.Where(r => r.EventID == PM.EventID).FirstOrDefault(); if (obj.Status == 1) { obj.Status = 0; } else { obj.Status = 1; } db.SaveChanges(); return(new Result() { IsSucess = true, ResultData = "Event Deactivated Successfully." }); } catch (Exception e) { return(new Error() { IsError = true, Message = e.Message }); } }
//Event Master public object SaveEvent(EventMasterParam b) { if (b.EventTypeID == 0) { return(new Error() { IsError = true, Message = "Required EventType" }); } var data = db.Tbl_EventMaster.FirstOrDefault(r => r.EventName == b.EventName); if (data != null) { return(new Error() { IsError = true, Message = "Duplicate Entry Not Allowed" }); } try { Tbl_EventMaster obj = new Tbl_EventMaster(); obj.EventTypeID = b.EventTypeID; obj.EventName = b.EventName; obj.StartDate = b.StartDate; obj.EndDate = b.EndDate; obj.Status = 1; obj.CreatedBy = 1; obj.CreatedDate = System.DateTime.Today.Date; obj.ModifiedBy = null; obj.ModifiedDate = System.DateTime.Today.Date; db.Tbl_EventMaster.Add(obj); db.SaveChanges(); return(new Result() { IsSucess = true, ResultData = "Created Event" }); } catch (Exception e) { return(new Error() { IsError = true, Message = e.Message }); } }