public ContainerVisitor UpdateVisitorOutByID(ContainerVisitor obj) { var result = new ContainerVisitor(); try { using (var ctx = new BIG_VMSEntities()) { var reTrnVisitor = ctx.TRN_VISITOR.Where(o => o.AUTO_ID == obj.TRN_VISITOR.AUTO_ID).FirstOrDefault(); if (reTrnVisitor != null) { reTrnVisitor.STATUS = 2; ctx.SaveChanges(); result.Status = true; } else { result.Status = false; } } } catch (Exception ex) { result.Status = false; result.ExceptionMessage = ex.Message; } return(result); }
public ContainerVisitor Update(ContainerVisitor obj) { var result = new ContainerVisitor(); using (var ctx = new BIG_VMSEntities()) { try { var visitorObj = obj.TRN_VISITOR; var updateData = ctx.TRN_VISITOR.Where(o => o.AUTO_ID == obj.TRN_VISITOR.AUTO_ID).FirstOrDefault(); if (updateData != null) { if (visitorObj.TRN_ATTACHEDMENT.Count > 0) { var attach = ctx.TRN_ATTACHEDMENT.Where(o => o.VISITOR_ID == visitorObj.AUTO_ID).FirstOrDefault(); if (attach != null) { attach.CONTACT_PHOTO = visitorObj.TRN_ATTACHEDMENT.FirstOrDefault().CONTACT_PHOTO; attach.ID_CARD_PHOTO = visitorObj.TRN_ATTACHEDMENT.FirstOrDefault().ID_CARD_PHOTO; } else { var att = new TRN_ATTACHEDMENT(); att.CONTACT_PHOTO = visitorObj.TRN_ATTACHEDMENT.FirstOrDefault().CONTACT_PHOTO; att.ID_CARD_PHOTO = visitorObj.TRN_ATTACHEDMENT.FirstOrDefault().ID_CARD_PHOTO; att.VISITOR_ID = visitorObj.AUTO_ID; } } updateData.ID_CARD = visitorObj.ID_CARD; updateData.FIRST_NAME = visitorObj.FIRST_NAME; updateData.LAST_NAME = visitorObj.LAST_NAME; updateData.CAR_TYPE_ID = visitorObj.CAR_TYPE_ID; updateData.LICENSE_PLATE = visitorObj.LICENSE_PLATE; updateData.LICENSE_PLATE_PROVINCE_ID = visitorObj.LICENSE_PLATE_PROVINCE_ID; updateData.REASON_ID = visitorObj.REASON_ID; updateData.CONTACT_EMPLOYEE_ID = visitorObj.CONTACT_EMPLOYEE_ID; updateData.UPDATED_DATE = DateTime.Now; updateData.UPDATED_BY = visitorObj.UPDATED_BY; ctx.SaveChanges(); result.Status = true; result.Message = "บันทึกข้อมูลเรียบร้อย"; } else { result.Status = false; result.Message = "แก้ไขไม่สำเร็จ"; } } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerVisitor Delete(ContainerVisitor obj) { var result = new ContainerVisitor(); using (var ctx = new BIG_VMSEntities()) { try { var deleteAttach = ctx.TRN_ATTACHEDMENT.Where(o => o.VISITOR_ID == obj.TRN_VISITOR.AUTO_ID).FirstOrDefault(); var deleteData = ctx.TRN_VISITOR.Where(o => o.AUTO_ID == obj.TRN_VISITOR.AUTO_ID).FirstOrDefault(); if (deleteAttach != null) { ctx.TRN_ATTACHEDMENT.Remove(deleteAttach); } ctx.TRN_VISITOR.Remove(deleteData); ctx.SaveChanges(); result.Status = true; result.Message = "Delete Successful"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerAppointment Create(ContainerAppointment obj) { var result = new ContainerAppointment(); using (var ctx = new BIG_VMSEntities()) { try { ctx.TRN_APPOINTMENT.Add(obj.TRN_APPOINTMENT); ctx.SaveChanges(); result.Status = true; result.Message = "Save Successful"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerBlackList Create(ContainerBlackList obj) { var result = new ContainerBlackList(); using (var ctx = new BIG_VMSEntities()) { try { ctx.TRN_BLACKLIST.Add(obj.TRN_BLACKLIST); ctx.SaveChanges(); result.Status = true; result.Message = "Save Successful"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerCarModel Create(ContainerCarModel obj) { var result = new ContainerCarModel(); using (var ctx = new BIG_VMSEntities()) { try { ctx.MAS_CAR_MODEL.Add(obj.MAS_CAR_MODEL); ctx.SaveChanges(); result.Status = true; result.Message = "Save Successful"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerAuthentication Create(ContainerAuthentication obj) { var result = new ContainerAuthentication(); using (var ctx = new BIG_VMSEntities()) { try { ctx.MEMBER_LOGON.Add(obj.MEMBER_LOGON); ctx.SaveChanges(); result.Status = true; result.Message = "Save Successful"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerAppointment UpdateStatus(int autoID) { var result = new ContainerAppointment(); using (var ctx = new BIG_VMSEntities()) { try { var data = ctx.TRN_APPOINTMENT.Where(o => o.AUTO_ID == autoID).FirstOrDefault(); data.STATUS = "เข้าพบแล้ว"; ctx.SaveChanges(); result.Status = true; result.Message = "Update Successful"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerBlackList Delete(ContainerBlackList obj) { var result = new ContainerBlackList(); using (var ctx = new BIG_VMSEntities()) { try { var deleteData = ctx.TRN_BLACKLIST.Where(o => o.AUTO_ID == obj.TRN_BLACKLIST.AUTO_ID).FirstOrDefault(); ctx.TRN_BLACKLIST.Remove(deleteData); ctx.SaveChanges(); result.Status = true; result.Message = "Delete Successful"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }
public ContainerVisitor Create(ContainerVisitor obj) { var result = new ContainerVisitor(); using (var ctx = new BIG_VMSEntities()) { try { var data = ctx.TRN_VISITOR.Add(obj.TRN_VISITOR); ctx.SaveChanges(); result.ResultObj = obj.TRN_VISITOR; result.Status = true; result.Message = "Save Successful"; } catch (DbEntityValidationException ex) { result.Status = false; result.Message = ex.Message.ToString(); } } return(result); }