public bool DeleteHubAllocation(HubAllocation hubAllocation) { if (hubAllocation == null) return false; _unitOfWork.HubAllocationRepository.Delete(hubAllocation); _unitOfWork.Save(); return true; }
public bool EditHubAllocation(HubAllocation hubAllocation) { _unitOfWork.HubAllocationRepository.Edit(hubAllocation); var requisition = _unitOfWork.ReliefRequisitionRepository.FindBy(r => r.RequisitionID == hubAllocation.RequisitionID).Single(); requisition.Status = 3; _unitOfWork.Save(); return true; }
public ActionResult HubAllocationDetail(Cats.Models.HubAllocation hubAllocation) { var seleList = new SelectList(_hubService.GetAllHub(), "HubId", "Name"); ViewBag.HubId = seleList; IEnumerable <Cats.Models.HubAllocation> detail = _projectCodeAllocationService.Get( t => t.HubID == hubAllocation.HubID); return(View(detail)); }
public ActionResult InserRequisition(ICollection <RequisitionViewModel> requisitionDetail, FormCollection form, string datepicker, string rNumber) { if (rNumber.Trim() == string.Empty) { return(RedirectToAction("ApprovedRequisitions", "HubAllocation")); } var userName = HttpContext.User.Identity.Name; var user = _userAccountService.GetUserDetail(userName); if (ModelState.IsValid && requisitionDetail != null) { string hub = form["hub"].ToString(CultureInfo.InvariantCulture); //retrives Hub id from the view DateTime date; try { date = DateTime.Parse(datepicker); //checkes if date is ethiopian date. if it is then it will enter to the catch and convert to gragorian to persist. } catch (Exception exception) { var log = new Logger(); log.LogAllErrorsMesseges(exception, _log); var strEth = new getGregorianDate(); date = strEth.ReturnGregorianDate(datepicker); } foreach (RequisitionViewModel appRequisition in requisitionDetail) { var newHubAllocation = new HubAllocation { AllocatedBy = user.UserProfileID, RequisitionID = appRequisition.RequisitionId, AllocationDate = date, ReferenceNo = rNumber, HubID = int.Parse(hub) }; _hubAllocationService.AddHubAllocation(newHubAllocation); } return(RedirectToAction("ApprovedRequisitions", "HubAllocation")); } return(RedirectToAction("ApprovedRequisitions", "HubAllocation")); }
public void AddHubAllocations(IEnumerable<Allocation> allocations, int userProfileId) { foreach (var appRequisition in allocations) { var newHubAllocation = new HubAllocation { AllocatedBy = userProfileId, RequisitionID = appRequisition.ReqId, AllocationDate = DateTime.Now.Date, ReferenceNo = "001", HubID = appRequisition.HubId }; AddHubAllocation(newHubAllocation); } }
public JsonResult Save(List<Allocation> allocation) { var userName = HttpContext.User.Identity.Name; var user = _userAccountService.GetUserDetail(userName); try { foreach (Allocation appRequisition in allocation) { var newHubAllocation = new HubAllocation(); newHubAllocation.AllocatedBy = user.UserProfileID; newHubAllocation.RequisitionID = appRequisition.ReqId; newHubAllocation.AllocationDate = DateTime.Now.Date; newHubAllocation.ReferenceNo = "001"; newHubAllocation.HubID = appRequisition.HubId; _HubAllocationService.AddHubAllocation(newHubAllocation); } ModelState.AddModelError("Success","Allocation is Saved."); return Json(new { success = true }); } catch (Exception ex) { return Json(new { success = false, errorMessage = ex.Message }); } }
public bool EditHubAllocation(HubAllocation hubAllocation) { _unitOfWork.HubAllocationRepository.Edit(hubAllocation); _unitOfWork.Save(); return true; }
public ActionResult InserRequisition(ICollection<RequisitionViewModel> requisitionDetail, FormCollection form, string datepicker, string rNumber) { if (rNumber.Trim() == string.Empty) return RedirectToAction("ApprovedRequisitions", "HubAllocation"); var userName = HttpContext.User.Identity.Name; var user = _userAccountService.GetUserDetail(userName); if (ModelState.IsValid && requisitionDetail !=null ) { string hub = form["hub"].ToString(CultureInfo.InvariantCulture); //retrives Hub id from the view DateTime date; try { date = DateTime.Parse(datepicker); //checkes if date is ethiopian date. if it is then it will enter to the catch and convert to gragorian to persist. } catch (Exception exception) { var log = new Logger(); log.LogAllErrorsMesseges(exception,_log); var strEth = new getGregorianDate(); date = strEth.ReturnGregorianDate(datepicker); } foreach (RequisitionViewModel appRequisition in requisitionDetail) { var newHubAllocation = new HubAllocation { AllocatedBy = user.UserProfileID, RequisitionID = appRequisition.RequisitionId, AllocationDate = date, ReferenceNo = rNumber, HubID = int.Parse(hub) }; _hubAllocationService.AddHubAllocation(newHubAllocation); } return RedirectToAction("ApprovedRequisitions", "HubAllocation"); } return RedirectToAction("ApprovedRequisitions", "HubAllocation"); }
public bool CreateRequisitonForTransfer(Transfer transfer) { if (transfer != null) { var fdp = _unitOfWork.FDPRepository.FindBy(m => m.HubID == transfer.DestinationHubID).FirstOrDefault(); if (fdp != null) { List<LedgerService.AvailableShippingCodes> availableSINumbers=new List<LedgerService.AvailableShippingCodes>(); var relifRequisition = new ReliefRequisition() { //RegionalRequestID = regionalRequest.RegionalRequestID, //Round = regionalRequest.Round, Month = transfer.CreatedDate.Month, ProgramID = transfer.ProgramID, CommodityID = transfer.CommodityID, RequestedDate = transfer.CreatedDate, //RationID = regionalRequest.RationID RequisitionNo = Guid.NewGuid().ToString(), RegionID = fdp.AdminUnit.AdminUnit2.AdminUnit2.AdminUnitID, ZoneID = fdp.AdminUnit.AdminUnit2.AdminUnitID, Status = (int) ReliefRequisitionStatus.Draft, }; _unitOfWork.ReliefRequisitionRepository.Add(relifRequisition); var relifRequistionDetail = new ReliefRequisitionDetail(); relifRequistionDetail.DonorID = 1; relifRequistionDetail.FDPID = fdp.FDPID; relifRequistionDetail.BenficiaryNo = 0; //since there is no need of benficiaryNo on transfer relifRequistionDetail.CommodityID = transfer.CommodityID; relifRequistionDetail.Amount = transfer.Quantity; relifRequisition.ReliefRequisitionDetails.Add(relifRequistionDetail); // save hub allocation var hubAllocation = new HubAllocation { AllocatedBy = 1, RequisitionID = relifRequisition.RequisitionID, AllocationDate = transfer.CreatedDate, ReferenceNo = "001", HubID = transfer.SourceHubID }; _unitOfWork.HubAllocationRepository.Add(hubAllocation); //relifRequisition.RequisitionNo = String.Format("REQ-{0}", relifRequisition.RequisitionID); relifRequisition.RequisitionNo = transfer.ReferenceNumber; relifRequisition.Status = (int)ReliefRequisitionStatus.HubAssigned; if(transfer.Commodity.ParentID==null) { availableSINumbers = GetFreeSICodesByCommodity(transfer.SourceHubID, transfer.CommodityID); } else { availableSINumbers = GetFreeSICodesByCommodityChild(transfer.SourceHubID, transfer.CommodityID); } var siNumberExist = availableSINumbers.Any(availableShippingCode => availableShippingCode.siCodeId == transfer.ShippingInstructionID); if (!siNumberExist) { return false; } _unitOfWork.Save(); SIPCAllocation allocation = new SIPCAllocation { Code = transfer.ShippingInstructionID, AllocatedAmount = transfer.Quantity, AllocationType = "SI", RequisitionDetailID = relifRequistionDetail.RequisitionDetailID }; _unitOfWork.SIPCAllocationRepository.Add(allocation); relifRequisition.Status = (int) ReliefRequisitionStatus.ProjectCodeAssigned; relifRequisition.RequisitionNo = String.Format("REQ-{0}", relifRequisition.RequisitionID); _unitOfWork.Save(); if (!PostSIAllocation(relifRequisition.RequisitionID,transfer.CommoditySourceID)) { return false; } return true; } } return false; }