public bool CheckExistingSupplierSchedule(DataContracts.Schedulers.DC_Supplier_Schedule_RQ RQ) { try { using (ConsumerEntities context = new ConsumerEntities()) { //var search = from ac in context.Supplier_Schedule where ac.Supplier_ID equals RQ.sup var search = (from ac in context.Supplier_Schedule //join r in RQ on ac.Supplier_ID equals r.Suppllier_ID where ac.Supplier_ID == RQ.Suppllier_ID && RQ.Entities.Contains(ac.Entity) select ac).ToList(); if (search.Count > 0) { return(false); } return(true); } } catch (Exception ex) { throw new FaultException <DataContracts.DC_ErrorStatus>(new DataContracts.DC_ErrorStatus { ErrorMessage = "Error while updating accomodation contacts", ErrorStatusCode = System.Net.HttpStatusCode.InternalServerError }); } }
public bool UpdateSupplierSchedule(DataContracts.Schedulers.DC_Supplier_Schedule_RQ RQ) { try { using (ConsumerEntities context = new ConsumerEntities()) { var search = (from ac in context.Supplier_Schedule where ac.SupplierScheduleID == RQ.SupplierScheduleID select ac).First(); if (RQ.IsActive == true) { var Activecount = (from a in context.Supplier_Schedule where a.Supplier_ID == RQ.Suppllier_ID && a.Entity == RQ.Enitity && a.IsActive == true select a).Count(); if (Activecount == 0) { search.IsActive = RQ.IsActive; search.Edit_Date = RQ.Edit_Date; search.Edit_User = RQ.Edit_User; context.SaveChanges(); } } else if (search != null) { search.IsActive = RQ.IsActive; search.Edit_Date = RQ.Edit_Date; search.Edit_User = RQ.Edit_User; context.SaveChanges(); } return(true); } } catch { throw new FaultException <DataContracts.DC_ErrorStatus>(new DataContracts.DC_ErrorStatus { ErrorMessage = "Error while updating accomodation contacts", ErrorStatusCode = System.Net.HttpStatusCode.InternalServerError }); } }
public IList <DataContracts.Schedulers.DC_Supplier_Schedule_RS> GetScheduleBySupplier(DataContracts.Schedulers.DC_Supplier_Schedule_RQ RQ) { try { using (ConsumerEntities context = new ConsumerEntities()) { var search = from sup in context.Supplier_Schedule where sup.Supplier_ID == RQ.Suppllier_ID //&& sup.Status=="Active" select sup; int total; total = search.Count(); if (RQ.PageSize == 0) { RQ.PageSize = 10; } int skip = (RQ.PageNo ?? 0) * (RQ.PageSize ?? 0); var canPage = skip < total; var result = from a in search select new DataContracts.Schedulers.DC_Supplier_Schedule_RS { SupplierScheduleID = a.SupplierScheduleID, Suppllier_ID = a.Supplier_ID, Entity = a.Entity, FrequencyTypeCode = a.FrequencyTypeCode, TotalSize = total, Status = a.Status, }; return(result.OrderBy(p => p.Suppllier_ID).Skip(skip).Take((RQ.PageSize ?? total)).ToList()); } } catch (Exception ex) { throw new FaultException <DataContracts.DC_ErrorStatus>(new DataContracts.DC_ErrorStatus { ErrorMessage = "Error while fetching City Master", ErrorStatusCode = System.Net.HttpStatusCode.InternalServerError }); } }
public IList <DataContracts.Schedulers.DC_Supplier_Schedule> GetSchedule(DataContracts.Schedulers.DC_Supplier_Schedule_RQ RQ) { try { using (ConsumerEntities context = new ConsumerEntities()) { var search = from sup in context.Supplier_Schedule select sup; if (RQ.Suppllier_ID != Guid.Empty) { //Guid _newID = RQ.Suppllier_ID; var result = from a in search where a.Supplier_ID == RQ.Suppllier_ID select new DataContracts.Schedulers.DC_Supplier_Schedule { SupplierScheduleID = a.SupplierScheduleID, Suppllier_ID = a.Supplier_ID, ISXMLSupplier = a.ISXMLSupplier, ISUpdateFrequence = (a.ISUpdateFrequence ?? false), FrequencyTypeCode = a.FrequencyTypeCode, Recur_No = (a.Recur_No ?? 0), MonthOfYear = a.MonthOfYear, DayOfWeek = a.DayOfWeek, DateOfMonth = a.DateOfMonth, WeekOfMonth = a.WeekOfMonth, StartTime = a.StartTime, EndTime = a.EndTime, Status = a.Status, Create_Date = a.Create_Date, Create_User = a.Create_User, Edit_Date = a.Edit_Date, Edit_User = a.Edit_User, Entity = a.Entity, User_Role_Id = a.User_Role_Id, IsActive = a.IsActive.Value, }; return(result.ToList()); } else if (RQ.SupplierScheduleID != Guid.Empty) { var result = from a in search where a.SupplierScheduleID == RQ.SupplierScheduleID select new DataContracts.Schedulers.DC_Supplier_Schedule { SupplierScheduleID = a.SupplierScheduleID, Suppllier_ID = a.Supplier_ID, ISXMLSupplier = a.ISXMLSupplier, ISUpdateFrequence = (a.ISUpdateFrequence ?? false), FrequencyTypeCode = a.FrequencyTypeCode, Recur_No = (a.Recur_No ?? 0), MonthOfYear = a.MonthOfYear, DayOfWeek = a.DayOfWeek, DateOfMonth = a.DateOfMonth, WeekOfMonth = a.WeekOfMonth, StartTime = a.StartTime, EndTime = a.EndTime, Status = a.Status, Create_Date = a.Create_Date, Create_User = a.Create_User, Edit_Date = a.Edit_Date, Edit_User = a.Edit_User, Entity = a.Entity, User_Role_Id = a.User_Role_Id, IsActive = a.IsActive.Value, }; return(result.ToList()); } else { return(null); } } } catch (Exception ex) { throw new FaultException <DataContracts.DC_ErrorStatus>(new DataContracts.DC_ErrorStatus { ErrorMessage = "Error while fetching City Master", ErrorStatusCode = System.Net.HttpStatusCode.InternalServerError }); } }