public static InRequest Create(int requestNumber, string requestDocumentNumber, string purchaseOrderNumber, string notes, Guid?projectId, Guid cellarId, InRequestStatus status, TypeInRequest typeInRequest, Guid creatorid, DateTime createDateTime, string personInCharge, string companyName, string comment) { var @inRequest = new InRequest { Id = Guid.NewGuid(), RequestNumber = requestNumber, RequestDocumentNumber = requestDocumentNumber, Notes = notes, ProjectId = projectId, CellarId = cellarId, Comment = comment, Status = status, TypeInRequest = typeInRequest, CreationTime = createDateTime, ActivationDate = createDateTime, CreatorUserId = creatorid, PurchaseOrderNumber = purchaseOrderNumber, PersonInCharge = personInCharge, CompanyName = companyName, IsDeleted = false, }; return(@inRequest); }
public IPagedList <Asset> SearchAssets(string query, int?page, TypeInRequest type, string company) { int defaultPageSize = 10; int currentPageIndex = page.HasValue ? page.Value - 1 : 0; var @entities = _inRequestManager.SearchAsset(query, type, company); int totalCount = @entities.Count(); return(@entities.OrderByDescending(p => p.Code).Skip(currentPageIndex * defaultPageSize).Take(defaultPageSize).MapTo <List <Asset> >().ToPagedList(currentPageIndex, defaultPageSize, totalCount)); }
public ActionResult SearchArticulos(string q, int?typeInRequestValue, int?page) { SearchAssetPartialInput newList = new SearchAssetPartialInput(); newList.Query = q; newList.TypeInRequestValue = typeInRequestValue.ToString(); ViewBag.Query = q; int type = Convert.ToInt32(typeInRequestValue); TypeInRequest temp = (TypeInRequest)type; newList.Entities = _inRequestService.SearchAssets(q, page, temp, _currentUser.CompanyName); newList.TotalItem = _inRequestService.TotalCount(q, page, temp, _currentUser.CompanyName); return(PartialView("_searchAssetPartial", newList)); }
//antes de stock decia asset public IQueryable <Asset> SearchAsset(string q, TypeInRequest type, string company) { string query = ""; if (q != null) { query = q.ToLower(); } var temp = (int)type; var temp1 = (AssetType)temp; var assets = _assetRepository.GetAll().Where(a => a.AssetType == temp1 && a.CompanyName.Equals(company)); //assets = assets._stockRepository.GetAll().Where(b => b.AssetQtyInputs - b.AssetQtyOutputs - b.AssetQtyOutputsBlocked == 0); assets = assets.Where(a => a.IsDeleted == false && a.Name.ToLower().Contains(query) || a.Name.ToLower().Equals(query) || a.Code.ToLower().Contains(query) || a.Code.ToLower().Equals(query)); return(assets.Include(a => a.Category).Include(a => a.Stocks).OrderBy(a => a.Name)); }
public int TotalCount(string query, int?page, TypeInRequest type, string company) { var @entities = _inRequestManager.SearchAsset(query, type, company); return(@entities.Count()); }
public void Create(CreateInRequestInput input) { //if (_inRequestManager.InRequestExist(input.RequestDocumentNumber, input.Id, input.CompanyName)) //{ // throw new UserFriendlyException("Existe una solicitud con el mismo numero de Solicitud Fisica."); //} TypeInRequest temp = (TypeInRequest)input.TypeInRequestValue; InRequestStatus temp1; temp1 = InRequestStatus.Active; var requestNumber = GetNextRequestNumber(input.CompanyName); var @entityInRequest = InRequest.Create(requestNumber, requestNumber.ToString(), input.PurchaseOrderNumber, input.Notes, null, input.CellarId, temp1, temp, input.CreatorGuidId.Value, _dateTime.Now, input.PersonInCharge, input.CompanyName, input.Comment); IList <Detail> @details = new List <Detail>(); foreach (var item in input.DetailsRequest) { var @entityDetail = Detail.Create(@entityInRequest.Id, null, null, item.AssetId, item.NameAsset, item.StockAsset, Double.Parse(item.Price), input.CreatorGuidId.Value, _dateTime.Now, input.CompanyName); @details.Add(@entityDetail); } if (HasFile(input.Image1)) { string folderPath = "~/InRequestImages/"; string fileName = input.Image1.FileName;//input.Id + ".png" var mappedPath = HostingEnvironment.MapPath(folderPath) + fileName; var directory = new DirectoryInfo(HostingEnvironment.MapPath(folderPath)); if (directory.Exists == false) { directory.Create(); } string folderPathRelative = "../../InRequestImages/"; input.ImagePath1 = folderPathRelative + fileName; input.Image1.SaveAs(mappedPath); @entityInRequest.SetImage1(input.ImagePath1); } if (HasFile(input.Image2)) { string folderPath = "~/InRequestImages/"; string fileName = input.Image2.FileName;//input.Id + ".png" var mappedPath = HostingEnvironment.MapPath(folderPath) + fileName; var directory = new DirectoryInfo(HostingEnvironment.MapPath(folderPath)); if (directory.Exists == false) { directory.Create(); } string folderPathRelative = "../../InRequestImages/"; input.ImagePath2 = folderPathRelative + fileName; input.Image2.SaveAs(mappedPath); @entityInRequest.SetImage2(input.ImagePath2); } if (!string.IsNullOrEmpty(input.SignatureData)) { @entityInRequest.SetSignatureData(input.SignatureData); } _inRequestManager.Create(@entityInRequest, @details); }