public static Products ConvertToProduct(ProductDto prodDto) { Products product = new Products(); product.Category = CategoryDAO.getCategoryById(prodDto.CategoryId); if (prodDto.Code == null || prodDto.Code == "") { product.Code = null; } else { product.Code = prodDto.Code; } product.CreatedDate = DateTime.Now; product.Description = prodDto.Description; product.Name = prodDto.Name; product.Price = prodDto.Price; product.Status = StatusDAO.getStatusById(CONST.STATUS.ACTIVE); ProductDetails productDetail = new ProductDetails(); productDetail.ProductTypeId = StatusDAO.getStatusById(CONST.STATUS.P_IMAGE); productDetail.Status = StatusDAO.getStatusById(CONST.STATUS.ACTIVE); productDetail.CreatedDate = DateTime.Now; productDetail.Contents = prodDto.Image; productDetail.Product = product; product.ProductDetails.Add(productDetail); if (prodDto.Id != null) { product.Id = prodDto.Id; } return(product); }
public void MessageDelete(MessageDto message) { Messages mess = new Messages(); mess = Common.ConvertToMessages(message); mess.Status = StatusDAO.getStatusById(CONST.STATUS.DELETE); DAO.Execute(mess, Entity.MESSAGE, ExecuteType.UPDATE); }
public void DeleteProduct(string productCode) { var product = ProductDAO.getProductByCode(productCode); product.Status = StatusDAO.getStatusById(CONST.STATUS.DELETE); DAO.Execute(product, Entity.PRODUCT, ExecuteType.UPDATE); }
public void AddCategory(String CategoryName, String ParentName) { Categories category = new Categories(); category.Name = CategoryName; category.Status = StatusDAO.getStatusById(CONST.STATUS.ACTIVE); DAO.Execute(category, Entity.CATEGORY, ExecuteType.ADD); category = CategoryDAO.getCategoryByName(CategoryName); CategoryRelations rel = new CategoryRelations(); rel.Parent = CategoryDAO.getCategoryById(CONST.CATEGORY.CAT_TRANBAO); rel.Child = category; DAO.Execute(rel, Entity.CATEGORYRELATION, ExecuteType.ADD); }
public static Messages ConvertToMessages(MessageDto MessagesDto) { Messages Messages = new Messages(); if (MessagesDto != null) { Messages.Title = MessagesDto.Title; Messages.Status = StatusDAO.getStatusById(CONST.STATUS.UNREAD); Messages.Phone = MessagesDto.Phone; Messages.Name = MessagesDto.Name; Messages.Email = MessagesDto.Email; Messages.Address = MessagesDto.Address; Messages.CreatedDate = DateTime.Now; Messages.Contents = MessagesDto.Contents; } return(Messages); }
public static Comments ConvertToComments(CommentDto commentDto) { Comments comments = new Comments(); if (commentDto != null) { comments.Title = commentDto.Title; comments.Status = StatusDAO.getStatusById(CONST.STATUS.ACTIVE); comments.Product = ProductDAO.getProductById(commentDto.ProductId); comments.Phone = commentDto.Phone; comments.Name = commentDto.Name; comments.Email = commentDto.Email; comments.CreatedDate = DateTime.Now; comments.Content = commentDto.Content; } return(comments); }