public void Insert(DemandDTO dto) { if (dto.CenterId == 0) { Center center = new Center() { AddressNumber = dto.CenterAddressNumber, City = dto.CenterCity, District = dto.CenterDistrict, Document = dto.CenterDocument, Id = dto.CenterId, Name = dto.CenterName, Street = dto.CenterStreet, ZipCode = dto.CenterZipCode }; centerFacade.Insert(center); dto.CenterId = center.Id; } Demand demand = new Demand() { CenterID = dto.CenterId, Observations = dto.Observations, ProjectID = dto.ProjectId, Active = true, //TODO: deixar inativo TotalDelivered = dto.TotalDelivered, TotalNeed = dto.TotalNeed }; service.Post <DemandValidator>(demand); dto.DemandId = demand.Id; }
public DemandDTO updateDemand(DemandDTO demand) { var selectedDemand = uow.GetRepository <Demand>().Get(z => z.Id == demand.Id); selectedDemand = MapperFactory.CurrentMapper.Map(demand, selectedDemand); uow.GetRepository <Demand>().Update(selectedDemand); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <DemandDTO>(selectedDemand)); }
public static DemandDTO getDemandConfigDTO(Demand myDemand) { DemandDTO result = new DemandDTO(); ToolBox.MapObject(myDemand, result, true); result.dynPropValues = myDemand.getRealValues(); return(result); }
public HttpResponseMessage Get(int Id) { DemandDTO selectedTitle = service.getDemand(Id); if (selectedTitle == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title)); } return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle)); }
public static DemandDTO newDemand(DemandDTO demand) { using (carLeasingEntities db = new carLeasingEntities()) { Demand d = Casting.DemandCasting.castToDAL(demand); d.isDone = false; var dd = db.Demands.Add(d); db.SaveChanges(); dd.interestedId = demand.interestedId; db.SaveChanges(); return(Casting.DemandCasting.castToDTO(dd)); } }
public HttpResponseMessage Put(DemandDTO DemandDTO) { DemandDTO dto = service.updateDemand(DemandDTO); if (dto != null) { return(Request.CreateResponse(HttpStatusCode.OK, dto)); } else { return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title)); } }
public static void updateDemand(DemandDTO demand) { using (carLeasingEntities db = new carLeasingEntities()) { var d = db.Demands.FirstOrDefault(p => p.demanedId == demand.demanedId); d.fromDate = demand.fromDate; d.fromHour = demand.fromHour; d.Locationx = demand.Locationx; d.Locationy = demand.Locationy; d.toDate = demand.toDate; d.toHour = demand.toHour; db.SaveChanges(); } }
public DemandDTO newDemand(DemandDTO demand) { if (!uow.GetRepository <Demand>().GetAll().Any(z => z.Id == demand.Id)) { var adedDemand = MapperFactory.CurrentMapper.Map <Demand>(demand); adedDemand = uow.GetRepository <Demand>().Add(adedDemand); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <DemandDTO>(adedDemand)); } else { return(null); } }
public HttpResponseMessage Post(DemandDTO DemandDTO) { DemandDTO dto = service.newDemand(DemandDTO); if (dto != null) { HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, dto); message.Headers.Location = new Uri(Request.RequestUri + "/" + dto.Id); return(message); } else { return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.add_title)); } }
public static CarDTO lookForSuggest(DemandDTO demand) { using (carLeasingEntities db = new carLeasingEntities()) { var d = db.Supplies.FirstOrDefault(p => p.fromDate <= demand.fromDate && p.fromHour <= demand.fromHour && p.toDate >= demand.toDate && p.toHour >= demand.toHour); if (d != null) { var currentCar = db.Cars.FirstOrDefault(c => c.carNum == d.carNum); CarDTO carDTO = Casting.CarCasting.castToDTO(currentCar); return(carDTO); } return(null); } }
public void newDemand(string subItem, DemandDTO Demand) { switch (subItem) { case "newDemand": DemandsFunction.newDemand(Demand); break; case "updateDemand": DemandsFunction.updateDemand(Demand); break; default: break; } }
public static Demand castToDAL(DemandDTO demandDTO) { using (carLeasingEntities db = new carLeasingEntities()) { return(new Demand() { demanedId = demandDTO.demanedId, interestedId = demandDTO.interestedId, fromDate = demandDTO.fromDate, fromHour = demandDTO.fromHour, Locationx = demandDTO.Locationx, Locationy = demandDTO.Locationy, toDate = demandDTO.toDate, toHour = demandDTO.toHour, Transactions = db.Transactions.Where(p => p.demandId == demandDTO.demanedId).ToList(), User = db.Users.FirstOrDefault(p => p.userId == demandDTO.interestedId) }); } }
public void updateDemand(DemandDTO demand) { DemandsFunction.updateDemand(demand); }
public void newDemand(DemandDTO newDemand) { DemandsFunction.newDemand(newDemand); }
public static bool CreatTransaction(int supplyId, int demanedId, int userId) { using (carLeasingEntities db = new carLeasingEntities()) { Supply supply = db.Supplies.FirstOrDefault(s => s.supplyId == supplyId); if (demanedId == -1) { DemandDTO d = new DemandDTO() { fromDate = supply.fromDate, fromHour = supply.fromHour, Locationx = supply.carLocationx, Locationy = supply.carLocationy, toDate = supply.toDate, toHour = supply.toHour, interestedId = userId }; d = DemandsFunction.newDemand(d); demanedId = d.demanedId; } Demand demaned = db.Demands.FirstOrDefault(d => d.demanedId == demanedId); if (supply != null && demaned != null) { Transaction t = new Transaction() { demandId = demanedId, supplyId = supplyId, }; db.Transactions.Add(t); supply.isDone = true; demaned.isDone = true; if (supply.fromDate < demaned.fromDate) { Supply s = new Supply() { carNum = supply.carNum, carLocationx = supply.carLocationx, carLocationy = supply.carLocationy, supplyId = supply.supplyId, supplyU = supply.supplyU, fromDate = supply.fromDate, fromHour = supply.fromHour, toDate = demaned.fromDate, toHour = demaned.toHour, isDone = false }; db.Supplies.Add(s); } if (supply.toDate > demaned.toDate) { Supply s = new Supply() { carNum = supply.carNum, carLocationx = supply.carLocationx, carLocationy = supply.carLocationy, supplyId = supply.supplyId, supplyU = supply.supplyU, fromDate = demaned.toDate, fromHour = demaned.toHour, toDate = supply.toDate, toHour = supply.toHour, isDone = false }; db.Supplies.Add(s); } } db.SaveChanges(); SendEmail(supply); } return(true); }
public DemandDTO SaveDeamnd(DemandDTO demand) { demand.interestedId = Helper.getCurrentUserId(Request.GetRequestContext()); return(DemandsFunction.newDemand(demand)); }
public List <SupplyDTO> getFilterList(DemandDTO demand) { //demand.interestedId = Helper.getCurrentUserId(Request.GetRequestContext()); //DemandsFunction.newDemand(demand); return(SupplyFunction.getFilterList(demand)); }
//[AllowAnonymous] public CarDTO lookForSuggest(DemandDTO Demand) { return(SupplyFunction.lookForSuggest(Demand)); }
public static List <SupplyDTO> getFilterList(DemandDTO demand) { using (carLeasingEntities db = new carLeasingEntities()) { List <SupplyDTO> filterList = new List <SupplyDTO>(); //לולאה על כל הרכבים חישוב לפי נקודות שלהם foreach (var supply in db.Supplies) { var locA = new GeoCoordinate((double)demand.Locationx, (double)demand.Locationy); var locB = new GeoCoordinate((double)supply.carLocationx, (double)supply.carLocationy); double distance1 = locA.GetDistanceTo(locB); var d = db.Supplies.FirstOrDefault(p => p.fromDate <= demand.fromDate && p.fromHour <= demand.fromHour && p.toDate >= demand.toDate && p.toHour >= demand.toHour); if (/*d!=null&&*/ distance1 < 2000) { var s = Casting.SupplyCasting.CastToDTO(supply); filterList.Add(s); } } //if (demand.price) //{ // filterList = filterList.Where(p => p.price >= demand.price);//.ToList(); //} //if (demand.carCompany && demand.numSeats) //{ // foreach (var fl in filterList) // { // var cc = db.Cars.FirstOrDefault(p => p.carNum == fl.carNum); // if (cc.carCompany != demand.carCompany || cc.numSeats != demand.numSeats) // { // filterList.Remove(fl); // } // } //} //else if (demand.carCompany) //{ // foreach (var fl in filterList) // { // var cc = db.Cars.FirstOrDefault(p => p.carNum == fl.carNum); // if (cc.carCompany != demand.carCompany) // { // filterList.Remove(fl); // } // } //} //else //{ // foreach (var fl in filterList) // { // var cc = db.Cars.FirstOrDefault(p => p.carNum == fl.carNum); // if (cc.numSeats != demand.numSeats) // filterList.Remove(fl); // } //} return(filterList.Where(f => f.isDone == false).ToList()); // if(demand.toDate-demand.fromDate==0) //{ // demand.toHour - demand.fromHour; //} } }