/// <summary> /// Insert Assignment Type Information /// </summary> /// <param name="data">Assignment Type Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> AssignmentType(tblAssignmentType data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { int propertyFind = db.tblAssignmentType.Count(); if (propertyFind > 0) { data.id = db.tblAssignmentType.Max(s => s.id); } else { data.id = 1; } db.tblAssignmentType.Add(data); result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
/// <summary> /// Return Affected Row Or Error If Exist /// </summary> /// <param name="request">Assignment Type Information</param> /// <returns>Affected Row Or Error If Exist</returns> public static GetAssignmentTypeResponse AssignmentType(GetAssignmentTypeResponse request) { GetAssignmentTypeResponse response = new GetAssignmentTypeResponse(); try { tblAssignmentType AssignmentType = new tblAssignmentType() { id = request.AssignmentType.id, name = request.AssignmentType.name, detail = request.AssignmentType.detail, createDate = request.AssignmentType.createDate, upDateDate = DateTime.Now, deleteDate = null, state = "Active" }; var result = AssignmentTypeData.Update.AssignmentType(AssignmentType); if (result.Item1.Error) { response.Error.InfoError(result.Item1); } else { response.Message = result.Item2; } } catch (Exception ex) { response.Error.InfoError(ex); } return(response); }
/// <summary> /// Update Assignment Type Information /// </summary> /// <param name="data">Assignment Type Information</param> /// <returns>Number Affected Row</returns> public static Tuple <ErrorObject, string> AssignmentType(tblAssignmentType data) { erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { db.Entry(data).State = EntityState.Modified; result = db.SaveChanges(); Message = "Affected Row: " + result.ToString(); return(new Tuple <ErrorObject, string>(erros.IfError(false), Message)); } } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, string>(erros, String.Empty)); } }
/// <summary> /// Return Assignment Type Name /// </summary> /// <param name="id">Assignment Type ID</param> /// <returns>Assignment Type Name</returns> public static Tuple <ErrorObject, tblAssignmentType> GetAssignmentTypeName(int id) { tblAssignmentType AssignmentType = new tblAssignmentType(); erros = new ErrorObject(); try { using (HSCMEntities db = new HSCMEntities()) { AssignmentType.name = db.tblAssignmentType.Find(id).name; } erros.Error = false; return(new Tuple <ErrorObject, tblAssignmentType>(erros.IfError(false), AssignmentType)); } catch (Exception ex) { erros.InfoError(ex); return(new Tuple <ErrorObject, tblAssignmentType>(erros, AssignmentType)); } }