public bool DeleteSMS(SMS entity) { if (entity == null) return false; _unitOfWork.SMSRepository.Delete(entity); _unitOfWork.Save(); return true; }
public bool EditSMS(SMS entity) { _unitOfWork.SMSRepository.Edit(entity); _unitOfWork.Save(); return true; }
public ActionResult CreateDispatch(DispatchViewModel dispatchviewmodel) { ViewBag.UnitID = new SelectList(_unitService.GetAllUnit(), "UnitID", "Name", dispatchviewmodel.UnitID); if (ModelState.IsValid) { var reliefReq = _reliefRequisitionService.FindBy(n => n.RequisitionID == dispatchviewmodel.RequisitionId). FirstOrDefault(); DispatchViewModel dispatch = _dispatchService.CreateDispatchFromDispatchAllocation(dispatchviewmodel.DispatchAllocationID, 0); if (reliefReq != null) dispatch.PlanId = reliefReq.RegionalRequest.PlanID; dispatch.UserProfileID = dispatchviewmodel.UserProfileID; dispatch.PlateNo_Prime = dispatchviewmodel.PlateNo_Prime; dispatch.PlateNo_Trailer = dispatchviewmodel.PlateNo_Trailer; dispatch.GIN = dispatchviewmodel.GIN; dispatch.DispatchDate = dispatchviewmodel.DispatchDate; dispatch.DispatchedByStoreMan = dispatchviewmodel.DispatchedByStoreMan; dispatch.WeighBridgeTicketNumber = dispatchviewmodel.WeighBridgeTicketNumber; dispatch.DriverName = dispatchviewmodel.DriverName; dispatch.Remark = dispatchviewmodel.Remark; dispatch.UnitID = dispatchviewmodel.UnitID; dispatch.QuantityInUnit = dispatchviewmodel.QuantityInUnit; dispatch.QuantityPerUnit = dispatchviewmodel.QuantityPerUnit; dispatch.FDP = dispatchviewmodel.FDP; dispatch.Transporter = dispatchviewmodel.Transporter; dispatch.HubID = dispatchviewmodel.HubID; dispatch.RequisitionId = dispatchviewmodel.RequisitionId; dispatch.Quantity = UserProfile.PreferedWeightMeasurment.ToLower() == "mt" ? dispatchviewmodel.Quantity : dispatchviewmodel.Quantity / 10; _transactionService.SaveDispatchTransaction(dispatch); var contacts = _contactService.FindBy(c => c.FDPID == dispatch.FDPID); foreach (var contact in contacts) { var hub = _hubService.FindById(dispatch.HubID).Name; var message = new SmsOutgoingMessage() { //id = Guid.NewGuid().ToString(), to = contact.PhoneNo, message = "Hello," + contact.FirstName + " There is a new dispatch with GIN " + dispatch.GIN + " from " + hub + " hub. COMMODITY: " + dispatch.Commodity + " QUT: " + dispatch.Quantity + " MT." + "Transporter: '" + dispatch.Transporter + "' Plate No.: " + dispatch.PlateNo_Prime + "-" + dispatch.PlateNo_Trailer + " Date: " + DateTime.Today.ToShortDateString(), }; var sms = new SMS() { MobileNumber = contact.PhoneNo, Text = "Hello," + contact.FirstName + " There is a new dispatch with GIN " + dispatch.GIN + " from " + hub + " hub. COMMODITY: " + dispatch.Commodity + " QUT: " + dispatch.Quantity + " MT." + "Transporter: '" + dispatch.Transporter + "' Plate No.: " + dispatch.PlateNo_Prime + "-" + dispatch.PlateNo_Trailer + " Date: " + DateTime.Today.ToShortDateString(), Status = 1, InOutInd = "O", }; _smsService.AddSMS(sms); //var result = _smsGatewayService.SendSMS(message); } return RedirectToAction("Index", "Dispatch"); } return View(dispatchviewmodel); }
public bool AddSMS(SMS entity) { _unitOfWork.SMSRepository.Add(entity); _unitOfWork.Save(); return true; }
public ActionResult CreateDispatch(DispatchViewModel dispatchviewmodel) { ViewBag.UnitID = new SelectList(_unitService.GetAllUnit(), "UnitID", "Name", dispatchviewmodel.UnitID); if (ModelState.IsValid) { var reliefReq = _reliefRequisitionService.FindBy(n => n.RequisitionID == dispatchviewmodel.RequisitionId). FirstOrDefault(); DispatchViewModel dispatch = _dispatchService.CreateDispatchFromDispatchAllocation(dispatchviewmodel.DispatchAllocationID, 0); if (reliefReq != null) dispatch.PlanId = reliefReq.RegionalRequest.PlanID; dispatch.UserProfileID = dispatchviewmodel.UserProfileID; dispatch.PlateNo_Prime = dispatchviewmodel.PlateNo_Prime; dispatch.PlateNo_Trailer = dispatchviewmodel.PlateNo_Trailer; dispatch.GIN = dispatchviewmodel.GIN; dispatch.DispatchDate = dispatchviewmodel.DispatchDate; dispatch.DispatchedByStoreMan = dispatchviewmodel.DispatchedByStoreMan; dispatch.WeighBridgeTicketNumber = dispatchviewmodel.WeighBridgeTicketNumber; dispatch.DriverName = dispatchviewmodel.DriverName; dispatch.Remark = dispatchviewmodel.Remark; dispatch.UnitID = dispatchviewmodel.UnitID; dispatch.QuantityInUnit = dispatchviewmodel.QuantityInUnit; dispatch.QuantityPerUnit = dispatchviewmodel.QuantityPerUnit; dispatch.Quantity = dispatchviewmodel.QuantityPerUnit.GetValueOrDefault()/10; dispatch.FDP = dispatchviewmodel.FDP; dispatch.Transporter = dispatchviewmodel.Transporter; dispatch.HubID = dispatchviewmodel.HubID; dispatch.RequisitionId = dispatchviewmodel.RequisitionId; dispatch.DispatchID = dispatchviewmodel.DispatchID; dispatch.CommodityID = dispatchviewmodel.CommodityID; dispatch.CommodityChildID = dispatchviewmodel.CommodityChildID; //dispatch.Quantity = UserProfile.PreferedWeightMeasurment.ToLower() == "mt" ? dispatchviewmodel.Quantity : dispatchviewmodel.Quantity / 10; //if its being edited reverse previous transaction before saving the new one; var prevdispatch = _dispatchService.FindById(dispatchviewmodel.DispatchID.GetValueOrDefault()); if (prevdispatch != null) { var prevdispatchdetail = prevdispatch.DispatchDetails.FirstOrDefault(); _transactionService.SaveDispatchTransaction( new DispatchViewModel { CommodityID = prevdispatchdetail.CommodityID, Quantity = prevdispatchdetail.DispatchedQuantityInMT, QuantityInUnit = prevdispatchdetail.DispatchedQuantityInUnit, ShippingInstructionID = dispatchviewmodel.ShippingInstructionID, ProjectCodeID = dispatchviewmodel.ProjectCodeID, PlanId = dispatchviewmodel.PlanId, UnitID = dispatchviewmodel.UnitID, BidNumber = prevdispatch.BidNumber, CreatedDate = prevdispatch.CreatedDate, DispatchAllocationID = prevdispatch.DispatchAllocationID.GetValueOrDefault(), DispatchDate = prevdispatch.DispatchDate, DispatchID = prevdispatch.DispatchID, DispatchedByStoreMan = prevdispatch.DispatchedByStoreMan, DriverName = prevdispatch.DriverName, FDPID = prevdispatch.FDPID.GetValueOrDefault(), ProgramID = dispatchviewmodel.ProgramID, GIN = prevdispatch.GIN, HubID = prevdispatch.HubID, Month = prevdispatch.PeriodMonth, Year = prevdispatch.PeriodYear, PlateNo_Prime = prevdispatch.PlateNo_Prime, PlateNo_Trailer = prevdispatch.PlateNo_Trailer, Remark = prevdispatch.Remark, RequisitionNo = prevdispatch.RequisitionNo, Round = prevdispatch.Round, TransporterID = prevdispatch.TransporterID, UserProfileID = prevdispatch.UserProfileID, WeighBridgeTicketNumber = prevdispatch.WeighBridgeTicketNumber }, true); } _transactionService.SaveDispatchTransaction(dispatch); var contacts = _contactService.FindBy(c => c.FDPID == dispatch.FDPID); if (_dispatchService.FindByAllocationId(dispatchviewmodel.DispatchAllocationID)==null) { DispatchAllocation totalAllocated = _dispatchAllocationService.FindById(dispatchviewmodel.DispatchAllocationID); foreach (var contact in contacts) { var hub = _hubService.FindById(dispatch.HubID).Name; var sms = new SMS() { MobileNumber = contact.PhoneNo, Text = "Hello," + contact.FirstName + " There is a new dispatch from " + hub + " hub. COMMODITY: " + dispatch.Commodity + " QUT: " + totalAllocated.Amount + " MT." + "Strarting from:" + DateTime.Today.ToShortDateString(), Status = 1, InOutInd = "O", }; _smsService.AddSMS(sms); //var result = _smsGatewayService.SendSMS(message); } /* foreach (var contact in contacts) { var hub = _hubService.FindById(dispatch.HubID).Name; var message = new SmsOutgoingMessage() { //id = Guid.NewGuid().ToString(), to = contact.PhoneNo, message = "Hello," + contact.FirstName + " There is a new dispatch with GIN " + dispatch.GIN + " from " + hub + " hub. COMMODITY: " + dispatch.Commodity + " QUT: " + dispatch.Quantity + " MT." + "Transporter: '" + dispatch.Transporter + "' Plate No.: " + dispatch.PlateNo_Prime + "-" + dispatch.PlateNo_Trailer + " Date: " + DateTime.Today.ToShortDateString(), }; var sms = new SMS() { MobileNumber = contact.PhoneNo, Text = "Hello," + contact.FirstName + " There is a new dispatch with GIN " + dispatch.GIN + " from " + hub + " hub. COMMODITY: " + dispatch.Commodity + " QUT: " + dispatch.Quantity + " MT." + "Transporter: '" + dispatch.Transporter + "' Plate No.: " + dispatch.PlateNo_Prime + "-" + dispatch.PlateNo_Trailer + " Date: " + DateTime.Today.ToShortDateString(), Status = 1, InOutInd = "O", }; _smsService.AddSMS(sms); //var result = _smsGatewayService.SendSMS(message); } * */ } return RedirectToAction("Index", "Dispatch"); } return View(dispatchviewmodel); }