public long UpdateNotificationCheckList(NotificationCheckListObject notificationCheckList) { try { if (notificationCheckList == null) { return(-2); } var notificationCheckListEntity = ModelMapper.Map <NotificationCheckListObject, NotificationCheckList>(notificationCheckList); if (notificationCheckListEntity == null || notificationCheckListEntity.Id < 1) { return(-2); } using (var db = new ImportPermitEntities()) { db.NotificationCheckLists.Attach(notificationCheckListEntity); db.Entry(notificationCheckListEntity).State = EntityState.Modified; db.SaveChanges(); return(notificationCheckList.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long AddNotificationCheckList(NotificationCheckListObject notificationCheckList) { try { if (notificationCheckList == null) { return(-2); } var notificationCheckListEntity = ModelMapper.Map <NotificationCheckListObject, NotificationCheckList>(notificationCheckList); if (notificationCheckListEntity == null) { return(-2); } using (var db = new ImportPermitEntities()) { var returnStatus = db.NotificationCheckLists.Add(notificationCheckListEntity); db.SaveChanges(); return(returnStatus.Id); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public ActionResult EditNotificationCheckList(NotificationCheckListObject notificationCheckList) { var gVal = new GenericValidator(); try { //if (!ModelState.IsValid) //{ // gVal.Code = -1; // gVal.Error = "Plese provide all required fields and try again."; // return Json(gVal, JsonRequestBehavior.AllowGet); //} if (string.IsNullOrEmpty(notificationCheckList.CheckListItem.Trim())) { gVal.Code = -1; gVal.Error = "Please provide NotificationCheckList."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_NotificationCheckList"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldNotificationCheckList = Session["_NotificationCheckList"] as NotificationCheckListObject; if (oldNotificationCheckList == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldNotificationCheckList.CheckListItem = notificationCheckList.CheckListItem.Trim(); var docStatus = new NotificationCheckListServices().UpdateNotificationCheckList(oldNotificationCheckList); if (docStatus < 1) { gVal.Code = -1; gVal.Error = "NotificationCheckList information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldNotificationCheckList.Id; gVal.Error = "NotificationCheckList information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "NotificationCheckList information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public long UpdateNotificationCheckList(NotificationCheckListObject notificationCheckList) { try { return(_notificationCheckListManager.UpdateNotificationCheckList(notificationCheckList)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public ActionResult AddNotificationCheckList(NotificationCheckListObject notificationCheckList) { var gVal = new GenericValidator(); try { var companyInfo = GetLoggedOnUserInfo(); if (companyInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateNotificationCheckList(notificationCheckList); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new NotificationCheckListServices().AddNotificationCheckList(notificationCheckList); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "NotificationCheckList upload failed. Please try again." : "The NotificationCheckList Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "NotificationCheckList was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "NotificationCheckList notificationCheckListing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
private GenericValidator ValidateNotificationCheckList(NotificationCheckListObject notificationCheckList) { var gVal = new GenericValidator(); try { if (string.IsNullOrEmpty(notificationCheckList.CheckListItem)) { gVal.Code = -1; gVal.Error = "Please select provide NotificationCheckList."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "NotificationCheckList Validation failed. Please provide all required fields and try again."; return(gVal); } }