public ActionResult RoomEdit(ProductScheduleFormModel productScheduleToEdit, bool continueEditing)
 {
     if (ModelState.IsValid)
     {
         //Mapping to domain
         ProductSchedule productSchedule = Mapper.Map <ProductScheduleFormModel, ProductSchedule>(productScheduleToEdit);
         //if (String.IsNullOrEmpty(product.Slug))
         //{
         //    product.Slug = StringConvert.ConvertShortName(product.Name);
         //}
         ////this funcion not update all relationship value.
         _productScheduleService.EditProductSchedule(productSchedule);
         //update attribute
         foreach (var mapping in productSchedule.ProductScheduleAttributeMappings)
         {
             _productScheduleAttributeMappingService.EditProductScheduleAttributeMapping(mapping);
         }
         //update productpicture URL
         foreach (var picture in productSchedule.ProductSchedulePictureMappings)
         {
             _productSchedulePictureMappingService.EditProductSchedulePictureMapping(picture);
             _pictureService.EditPicture(picture.Picture);
         }
         return(continueEditing ? RedirectToAction("RoomEdit", "ProductSchedule", new { productScheduleId = productSchedule.Id })
               : RedirectToAction("Room", "ProductSchedule"));
     }
     else
     {
         var listProduct = _productService.GetProducts().Where(p => !p.ProductCategory.Name.Contains("Tour")).ToSelectListItems(-1);
         productScheduleToEdit.ListProduct = listProduct;
         return(View("RoomEdit", productScheduleToEdit));
     }
 }
        public ActionResult ScheduleCreate(ProductScheduleFormModel newProductSchedule, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                var listAttributeId = _productScheduleAttributeService.GetProductScheduleAttributes().Where(p => p.Type.Equals("Lịch trình")).Select(p => p.Id);
                //Mapping to domain
                ProductSchedule productSchedule = Mapper.Map <ProductScheduleFormModel, ProductSchedule>(newProductSchedule);

                //Create Product Schedule
                _productScheduleService.CreateProductSchedule(productSchedule);

                //Add ProductScheduleAttribute after product created
                productSchedule.ProductScheduleAttributeMappings = new Collection <ProductScheduleAttributeMapping>();
                //var listAttributeId = _productScheduleAttributeService.GetProductScheduleAttributes().Where(p => p.Type.Equals("Lịch trình")).Select(p => p.Id);
                foreach (var id in listAttributeId)
                {
                    productSchedule.ProductScheduleAttributeMappings.Add(
                        new ProductScheduleAttributeMapping()
                    {
                        ProductScheduleAttributeId = id, ProductScheduleId = productSchedule.Id
                    });
                }
                _productScheduleService.EditProductSchedule(productSchedule);
                return(continueEditing ? RedirectToAction("ScheduleEdit", "ProductSchedule", new { productScheduleId = productSchedule.Id })
                                : RedirectToAction("Schedule", "ProductSchedule"));
            }
            else
            {
                var listProduct = _productService.GetProducts().Where(p => p.ProductCategory.Name.Contains("Tour")).ToSelectListItems(-1);
                newProductSchedule.ListProduct = listProduct;
                return(View("ScheduleCreate", newProductSchedule));
            }
        }
示例#3
0
 public void CreateProductSchedule(ProductSchedule obj)
 {
     try
     {
         productScheduleRepository.Add(obj);
         SaveChange();
     }
     catch (Exception)
     {
     }
 }
示例#4
0
 public void EditProductSchedule(ProductSchedule obj)
 {
     try
     {
         var item = productScheduleRepository.Get(p => p.Id == obj.Id);
         item.MaxQuantity = obj.MaxQuantity;
         item.IsDeleted   = obj.IsDeleted;
         item.IsAvailable = obj.IsAvailable;
         productScheduleRepository.Update(item);
         SaveChange();
     }
     catch (Exception)
     {
     }
 }
        public ActionResult RoomCreate(ProductScheduleFormModel newProductSchedule, bool continueEditing)
        {
            if (ModelState.IsValid)
            {
                //Mapping to domain
                ProductSchedule productSchedule = Mapper.Map <ProductScheduleFormModel, ProductSchedule>(newProductSchedule);

                //Create Product Schedule
                _productScheduleService.CreateProductSchedule(productSchedule);

                //Add ProductScheduleAttribute after product created
                productSchedule.ProductScheduleAttributeMappings = new Collection <ProductScheduleAttributeMapping>();
                //Add Picture default for Labixa
                productSchedule.ProductSchedulePictureMappings = new Collection <ProductSchedulePictureMapping>();
                for (int i = 0; i < 11; i++)
                {
                    var  newPic = new Picture();
                    bool ismain = i == 0;
                    _pictureService.CreatePicture(newPic);
                    productSchedule.ProductSchedulePictureMappings.Add(
                        new ProductSchedulePictureMapping()
                    {
                        PictureId         = newPic.Id,
                        ProductScheduleId = productSchedule.Id,
                        IsMainPicture     = ismain,
                        DisplayOrder      = 0,
                    });
                }
                var listAttributeId = _productScheduleAttributeService.GetProductScheduleAttributes().Where(p => !p.Type.Equals("Lịch trình")).Select(p => p.Id);
                foreach (var id in listAttributeId)
                {
                    productSchedule.ProductScheduleAttributeMappings.Add(
                        new ProductScheduleAttributeMapping()
                    {
                        ProductScheduleAttributeId = id, ProductScheduleId = productSchedule.Id
                    });
                }
                _productScheduleService.EditProductSchedule(productSchedule);
                return(continueEditing ? RedirectToAction("RoomEdit", "ProductSchedule", new { productScheduleId = productSchedule.Id })
                                : RedirectToAction("Room", "ProductSchedule"));
            }
            else
            {
                var listProduct = _productService.GetProducts().Where(p => !p.ProductCategory.Name.Contains("Tour")).ToSelectListItems(-1);
                newProductSchedule.ListProduct = listProduct;
                return(View("RoomCreate", newProductSchedule));
            }
        }
示例#6
0
        public int AddOrUpdate(ProductSchedulesModel model)
        {
            try
            {
                if (model != null)
                {
                    string strSubject = System.Configuration.ConfigurationManager.AppSettings["ProductSchedule"];
                    string strBody = "<p>Product has been scheduled.</p>";
                    var currentusr = UserManager.Current();
                    if (currentusr != null)
                    {
                        var product = _productRepository.SelectById(int.Parse(model.Productid));
                        if (product != null)
                        {
                            var objSchedule = new ProductSchedule();

                            if (model.Row_Id != 0 && model.Row_Id != null)
                            {
                                objSchedule = _repository.GetById(model.Row_Id);
                            }
                            var color = _repository.GetAllColors().SingleOrDefault(col => col.Color == model.ColorCode);
                            objSchedule.CreateEvent = model.CreateEvent;
                            objSchedule.Title = model.Title;
                            objSchedule.Value = model.Value;

                            objSchedule.WebOptionMax = model.WebOptionMax;

                            if (color!=null)
                              objSchedule.ColorId = color.Row_Id;

                            objSchedule.SendEmail = model.SendEmail;
                            objSchedule.EmailAddress = model.EmailAddress;

                            if (!string.IsNullOrEmpty(model.EmailAddress))
                            {

                                objSchedule.ProductGroupId = product.ProductGroupId;
                            }
                            else
                                objSchedule.ProductGroupId = model.ProductGroupId;

                            if (!string.IsNullOrEmpty(product.XeroCode))
                            {
                                objSchedule.XeroCode = product.XeroCode.Trim();
                            }

                            if (model.Row_Id == 0 || model.Row_Id == null)
                            {
                                objSchedule.Created = DateTime.Now;
                                objSchedule.CreatedBy = currentusr.Row_Id;

                              var status =  _repository.Add(objSchedule);
                              if (status == 1 && !string.IsNullOrEmpty(model.EmailAddress))
                                {
                                  //  string strBody = "You have scheduled product";

                                    bool hasEmailSent = Email.sendemail(model.EmailAddress, "", strBody, true, false, strSubject);

                                }
                              return status;
                            }
                            if (model.Row_Id != 0 && model.Row_Id != null)
                            {
                                objSchedule.Updated = DateTime.Now;
                                objSchedule.UpdatedBy = currentusr.Row_Id;
                                var status = _repository.Update(objSchedule);
                                if (status == 1 && !string.IsNullOrEmpty(model.EmailAddress))
                                {
                                  //  string strBody = "You have scheduled product";
                                    bool hasEmailSent = Email.sendemail(model.EmailAddress, "", strBody, true, false, strSubject);

                                }

                                return status;
                            }

                        }
                    }
                }
            }
            catch (Exception ex)
            {

                string msg = ex.Message;
            }

            return 0;
        }
示例#7
0
 public DatPhongModel()
 {
     productSchedule = new ProductSchedule();
     checkIn         = DateTime.Now.Date.ToString();
     checkOut        = DateTime.Now.Date.ToString();
 }
示例#8
0
 public DatTourTrongNuocModel()
 {
     productSchedule = new ProductSchedule();
 }
 public int Update(ProductSchedule obj)
 {
     db.Entry(obj).State = EntityState.Modified;
        return db.SaveChanges();
 }
示例#10
0
 public int Add(ProductSchedule obj)
 {
     db.ProductSchedules.Add(obj);
        return db.SaveChanges();
 }
示例#11
0
        public IEnumerable <ProductSchedule> GetSimilarProductSchedule(ProductSchedule obj)
        {
            var listProductSchedule = GetProductSchedulesOfProduct(obj.ProductId);

            return(listProductSchedule);
        }