public ProductVersionModel GetProductVersionModelData(string productName, int?editionNumber, int?updateNumber) { ProductVersionModel = new ProductVersionModel() { ProductName = productName, EditionNumber = editionNumber, UpdateNumber = updateNumber }; return(ProductVersionModel); }
public int Execute(ProductVersionModel productVersionModel) { var newProductVersionModel = new Entities.Models.ProductVersion { DayOfPurchase = Convert.ToDateTime(productVersionModel.DayOfPurchase), SupplierId = productVersionModel.SupplierId, ExpirationDate = Convert.ToDateTime(productVersionModel.ExpirationDate), LinkScanTicket = productVersionModel.LinkScanTicket, Price = productVersionModel.Price, PricePerUnit = productVersionModel.PricePerUnit, MetricId = productVersionModel.MetricId, ProductId = productVersionModel.ProductId, QuantityInStock = productVersionModel.QuantityInStock, MetricQuantity = productVersionModel.MetricQuantity, }; _repo.ProductVersion.Create(newProductVersionModel); _repo.Save(); return(newProductVersionModel.Id); }
public void Execute(ProductVersionModel productVersionModel) { var productVersionToUpdate = _repo.ProductVersion.FindByCondition(x => x.Id == productVersionModel.Id).FirstOrDefault(); productVersionToUpdate.PricePerUnit = productVersionModel.PricePerUnit; productVersionToUpdate.MetricId = productVersionModel.MetricId; productVersionToUpdate.Price = productVersionModel.Price; productVersionToUpdate.ProductId = productVersionModel.ProductId; productVersionToUpdate.QuantityInStock = productVersionModel.QuantityInStock; productVersionToUpdate.MetricQuantity = productVersionModel.MetricQuantity; productVersionToUpdate.SupplierId = productVersionModel.SupplierId; productVersionToUpdate.DayOfPurchase = Convert.ToDateTime(productVersionModel.DayOfPurchase); productVersionToUpdate.ExpirationDate = Convert.ToDateTime(productVersionModel.ExpirationDate); productVersionToUpdate.LinkScanTicket = productVersionModel.LinkScanTicket; _repo.ProductVersion.Update(productVersionToUpdate); _repo.Save(); }
void createProductVersion(ProductsModel product, string reason) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { #region Tạo phiên bản san phẩm ProductVersionModel versionModel = new ProductVersionModel(); versionModel.ProductID = product.ID; versionModel.Reason = reason; versionModel.Version = product.Version + 1; versionModel.ID = (int)pt.Insert(versionModel); #endregion #region Tạo phiên bản bài thực hành của sản phẩm ArrayList lisBaiThucHanh = ProductBaiThucHanhLinkBO.Instance.FindByAttribute("ProductID", product.ID); if (lisBaiThucHanh.Count > 0) { foreach (var item in lisBaiThucHanh) { ProductBaiThucHanhLinkModel thisBTH = (ProductBaiThucHanhLinkModel)item; ProductBaiThucHanhLinkVersionModel bthVersion = new ProductBaiThucHanhLinkVersionModel(); bthVersion.ProductVersionID = versionModel.ID; bthVersion.BaiThucHanhID = thisBTH.BaiThucHanhID; bthVersion.ID = (int)pt.Insert(bthVersion); } } #endregion #region Tạo các phiên bản module sản phẩm ArrayList lisModules = ProductModuleLinkBO.Instance.FindByAttribute("ProductID", product.ID); if (lisModules.Count > 0) { foreach (var item in lisModules) { ProductModuleLinkModel thisModule = (ProductModuleLinkModel)item; ProductModuleLinkVersionModel moduleVersion = new ProductModuleLinkVersionModel(); moduleVersion.ProductVersionID = versionModel.ID; moduleVersion.Code = thisModule.Code; moduleVersion.CVersion = thisModule.CVersion; moduleVersion.Hang = thisModule.Hang; moduleVersion.Name = thisModule.Name; moduleVersion.Qty = thisModule.Qty; moduleVersion.Type = thisModule.Type; moduleVersion.ID = (int)pt.Insert(moduleVersion); } } #endregion #region Tạo phiên bản các file List <string> listFilePath = new List <string>(); ArrayList listFiles = ProductFileBO.Instance.FindByExpression(new Expression("ProductID", product.ID) .And(new Expression("Version", product.Version))); string ftpFolderPath = "Product\\BaiThucHanh\\" + product.Code + "\\" + versionModel.Version; if (!DocUtils.CheckExits(Path.GetDirectoryName(ftpFolderPath))) { DocUtils.MakeDir(Path.GetDirectoryName(ftpFolderPath)); } foreach (var item in listFiles) { ProductFileModel thisFile = (ProductFileModel)item; string path = Path.GetTempPath(); DocUtils.DownloadFile(path, Path.GetFileName(thisFile.Path), thisFile.Path); ProductFileModel file = new ProductFileModel(); file.ProductID = product.ID; file.Name = thisFile.Name; file.Length = thisFile.Length; file.LocalPath = path + "\\" + Path.GetFileName(thisFile.Path); file.Path = ftpFolderPath + "\\" + file.Name; file.Version = versionModel.Version; pt.Insert(file); listFilePath.Add(path + "\\" + Path.GetFileName(thisFile.Path)); } #endregion product.Version += 1; pt.Update(product); pt.CommitTransaction(); MessageBox.Show("Tạo phiên bản bài thực hành thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); foreach (string filePath in listFilePath) { if (!DocUtils.CheckExits(ftpFolderPath)) { DocUtils.MakeDir(ftpFolderPath); } DocUtils.UploadFile(filePath, ftpFolderPath); } } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
public IActionResult UpdateProductVersion([FromBody] ProductVersionModel productVersion) { _service.UpdateProductVersion(productVersion); return(Ok(productVersion)); }
public IActionResult CreateProductVersion([FromBody] ProductVersionModel productVersion) { var id = _service.CreateProductVersion(productVersion); return(Ok(productVersion)); }
protected ProductVersionFacade(ProductVersionModel model) : base(model) { }
public void UpdateProductVersion(ProductVersionModel productVersionModel) { new UpdateProductVersionOperation(_repository).Execute(productVersionModel); }
public int CreateProductVersion(ProductVersionModel productVersionModel) { return(new SaveProductVersionOperation(_repository).Execute(productVersionModel)); }
void createProductVersion(ProductsModel product, string reason) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { #region Tạo phiên bản san phẩm ProductVersionModel versionModel = new ProductVersionModel(); versionModel.ProductID = product.ID; versionModel.Reason = reason; versionModel.Version = product.Version; versionModel.ID = (int)pt.Insert(versionModel); #endregion #region Tạo phiên bản bài thực hành của sản phẩm ArrayList lisBaiThucHanh = ProductBaiThucHanhLinkBO.Instance.FindByAttribute("ProductID", product.ID); if (lisBaiThucHanh.Count > 0) { foreach (var item in lisBaiThucHanh) { ProductBaiThucHanhLinkModel thisBTH = (ProductBaiThucHanhLinkModel)item; ProductBaiThucHanhLinkVersionModel bthVersion = new ProductBaiThucHanhLinkVersionModel(); bthVersion.ProductVersionID = versionModel.ID; bthVersion.BaiThucHanhID = thisBTH.BaiThucHanhID; bthVersion.ID = (int)pt.Insert(bthVersion); } } #endregion #region Tạo các phiên bản module sản phẩm ArrayList lisModules = ProductModuleLinkBO.Instance.FindByAttribute("ProductID", product.ID); if (lisModules.Count > 0) { foreach (var item in lisModules) { ProductModuleLinkModel thisModule = (ProductModuleLinkModel)item; ProductModuleLinkVersionModel moduleVersion = new ProductModuleLinkVersionModel(); moduleVersion.ProductVersionID = versionModel.ID; moduleVersion.Code = thisModule.Code; moduleVersion.CVersion = thisModule.CVersion; moduleVersion.Hang = thisModule.Hang; moduleVersion.Name = thisModule.Name; moduleVersion.Qty = thisModule.Qty; moduleVersion.Type = thisModule.Type; moduleVersion.ID = (int)pt.Insert(moduleVersion); } } #endregion pt.CommitTransaction(); MessageBox.Show("Tạo phiên bản bài thực hành thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } }
public static string DeleteAttachment(int attachmentID, AttachmentProxy.References verifyRefType, int?verifyRefID = null) { string result = null; try { using (ConnectionContext connection = new ConnectionContext()) { // validate args AttachmentProxy proxy = Data_API.ReadRefTypeProxy <AttachmentProxy>(connection, attachmentID); result = proxy.FileName; if (verifyRefType == AttachmentProxy.References.None) // support delete no matter the type? { verifyRefType = proxy.RefType; } if (!verifyRefID.HasValue) // if no explicit refID provided, use the proxy { verifyRefID = proxy.RefID; } // type safe construction IAttachmentDestination model = null; switch (verifyRefType) { case AttachmentProxy.References.Actions: model = new ActionModel(connection, verifyRefID.Value); if (!(model as ActionModel).CanEdit()) // is user authorized to do the delete? { return(null); } break; case AttachmentProxy.References.Assets: model = new AssetModel(connection, verifyRefID.Value); break; //case AttachmentProxy.References.ChatAttachments: // break; case AttachmentProxy.References.CompanyActivity: { int organizationID = connection._db.ExecuteQuery <int>($"Select RefID from Notes WITH (NOLOCK) WHERE NoteID = {verifyRefID.Value}").Min(); model = new NoteModel(new OrganizationModel(connection, organizationID), verifyRefID.Value); } break; case AttachmentProxy.References.ContactActivity: { int userID = connection._db.ExecuteQuery <int>($"Select RefID from Notes WITH (NOLOCK) WHERE NoteID = {verifyRefID.Value}").Min(); model = new NoteModel(new UserModel(connection, userID), verifyRefID.Value); } break; //case AttachmentProxy.References.Contacts: // break; //case AttachmentProxy.References.CustomerHubLogo: // break; //case AttachmentProxy.References.None: // break; case AttachmentProxy.References.Organizations: model = new OrganizationModel(connection, verifyRefID.Value); break; case AttachmentProxy.References.ProductVersions: model = new ProductVersionModel(connection, verifyRefID.Value); break; case AttachmentProxy.References.Tasks: model = new TaskModel(connection, verifyRefID.Value); break; case AttachmentProxy.References.UserPhoto: case AttachmentProxy.References.Users: model = new UserModel(connection, verifyRefID.Value); break; case AttachmentProxy.References.WaterCooler: model = new WatercoolerMsgModel(connection, verifyRefID.Value); break; default: if (Debugger.IsAttached) { Debugger.Break(); } throw new Exception($"unrecognized RefType {verifyRefType} in DeleteAttachment"); } // do the delete Data_API.Delete(new AttachmentModel(model, attachmentID)); AttachmentFile file = new AttachmentFile(model, proxy); file.Delete(); } } catch (Exception ex) { Data_API.LogMessage(ActionLogType.Delete, ReferenceType.Attachments, attachmentID, "Unable to delete attachment", ex); } return(result); }