public async Task <IActionResult> CreateCharacteristic([FromBody] ProductCharacteristicChangeSetting characteristic)
        {
            if (characteristic == null)
            {
                ModelState.AddModelError(ErrorResponses.MissingBody, string.Empty);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var charModel = new ProductCharacteristic()
            {
                Name        = characteristic.Name,
                Description = characteristic.Description,
                Enabled     = characteristic.Enabled,
                Visible     = characteristic.Visible,
                ValueType   = characteristic.ValueType
            };
            var currentUser = await CurrentUserRetriever.GetCurrentUserAsync();

            var createCharacteristicCommand = new Jibberwock.Persistence.DataAccess.Commands.Products.CreateCharacteristic(Logger, currentUser, HttpContext.TraceIdentifier, WebApiConfiguration.Authorization.DefaultServiceId, null, charModel);

            var creationSuccessful = await createCharacteristicCommand.Execute(SqlServerDataSource);

            return(Created(string.Empty, creationSuccessful.Result));
        }
        public async Task <OperationDetail> CreateAsync(ProductCharacteristic entity)
        {
            var res = await _unitOfWork.ProductCharacteristicRepository.CreateAsync(entity);

            await _unitOfWork.SaveChangesAsync();

            return(res);
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProductCharacteristic productCharacteristic = _unitOfWork.Characteristics.FindById((int)id);

            _unitOfWork.Characteristics.Remove(productCharacteristic);
            _unitOfWork.Characteristics.Save();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
 private void AfterCheck(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Tag != null)
     {
         _characteristic = (ProductCharacteristic)e.Node.Tag;
         ProductChecked.Invoke();
     }
 }
Esempio n. 5
0
 public ActionResult Edit(ProductCharacteristic productCharacteristic)
 {
     if (ModelState.IsValid)
     {
         _unitOfWork.Characteristics.Update(productCharacteristic);
         _unitOfWork.Characteristics.Save();
         return(RedirectToAction("Index"));
     }
     ViewBag.CharacteristicsGroupId = new SelectList(_unitOfWork.CharacteristicsGroup.GetAll(), "Id", "Name", productCharacteristic.CharacteristicsGroupId);
     return(View(productCharacteristic));
 }
        public ClientManagerAddProductEditingPresenter(IKernel kernel, IClientManagerAddProductView view,
                                                       IServiceForControlProductMovementInClientOrder editor, ClientOrder order, ProductCharacteristic characteristic)
        {
            this._kernel         = kernel;
            this._order          = order;
            this._editor         = editor;
            this._view           = view;
            this._characteristic = characteristic;

            this._view.SetProductCharacteristic(this._characteristic);
            this._view.AddProduct += OnButtonAddProductClick;
            this._view.Back       += OnButtonCancelClick;
        }
Esempio n. 7
0
        // GET: ProductCharacteristics/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductCharacteristic productCharacteristic = _unitOfWork.Characteristics.GetWithInclude(x => x.Id == id, y => y.CharacteristicsGroup).Single();

            if (productCharacteristic == null)
            {
                return(HttpNotFound());
            }
            return(View(productCharacteristic));
        }
Esempio n. 8
0
        // GET: ProductCharacteristics/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductCharacteristic productCharacteristic = _unitOfWork.Characteristics.FindById((int)id);

            if (productCharacteristic == null)
            {
                return(HttpNotFound());
            }

            return(View(productCharacteristic));
        }
Esempio n. 9
0
        // GET: ProductCharacteristics/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductCharacteristic productCharacteristic = _unitOfWork.Characteristics.FindById((int)id);

            if (productCharacteristic == null)
            {
                return(HttpNotFound());
            }

            ViewBag.CharacteristicsGroupId = new SelectList(_unitOfWork.CharacteristicsGroup.GetAll(), "Id", "Name", productCharacteristic.CharacteristicsGroupId);
            return(View(productCharacteristic));
        }
        public async Task <IActionResult> DeleteProductCharacteristic([FromRoute] int id)
        {
            if (id == 0)
            {
                ModelState.AddModelError(ErrorResponses.InvalidId, string.Empty);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var charModel = new ProductCharacteristic()
            {
                Id = id
            };
            var currentUser = await CurrentUserRetriever.GetCurrentUserAsync();

            var deleteCharacteristicCommand = new Jibberwock.Persistence.DataAccess.Commands.Products.DeleteCharacteristic(Logger, currentUser, HttpContext.TraceIdentifier, WebApiConfiguration.Authorization.DefaultServiceId, null, charModel);

            var deleteSuccessful = await deleteCharacteristicCommand.Execute(SqlServerDataSource);

            switch (deleteSuccessful.Result)
            {
            case Persistence.DataAccess.Commands.Products.DeleteCharacteristicStatusCode.Success:
                return(StatusCode(StatusCodes.Status204NoContent));

            case Persistence.DataAccess.Commands.Products.DeleteCharacteristicStatusCode.AssociatedTier:
                ModelState.AddModelError(ErrorResponses.AssociatedWithTier, string.Empty);
                break;

            case Persistence.DataAccess.Commands.Products.DeleteCharacteristicStatusCode.AssociatedProduct:
                ModelState.AddModelError(ErrorResponses.AssociatedWithProduct, string.Empty);
                break;

            case Persistence.DataAccess.Commands.Products.DeleteCharacteristicStatusCode.Missing:
                return(NotFound());

            default:
                throw new ArgumentOutOfRangeException("This operation's return value was unexpected.");
            }

            // We've only reached this point if there's been an error in the model state
            return(BadRequest(ModelState));
        }
Esempio n. 11
0
        /// <summary>
        /// Updates the product image.
        /// </summary>
        /// <param name="productID">The product identifier.</param>
        /// <param name="file">The image file.</param>
        /// <returns>The image identifier</returns>
        public async Task <string> UpdateProductImage(int productID, IFormFile file)
        {
            string imageID = null;

            using (var fileStream = file.OpenReadStream())
                using (var ms = new MemoryStream())
                {
                    fileStream.CopyTo(ms);
                    imageID = DriveAPI.UploadImage(ms, file.FileName);
                }

            ProductCharacteristic characteristic = await this.unitOfWork.Set <ProductCharacteristic>()
                                                   .Where(pc => pc.ProductID == productID && pc.Characteristic.Name == "Image")
                                                   .FirstOrDefaultAsync();

            DriveAPI.DeleteFile(characteristic.Value);
            characteristic.Value = imageID;

            await this.unitOfWork.SaveAsync();

            return(imageID);
        }
        public async Task <IActionResult> UpdateProductCharacteristic([FromRoute] int id, [FromBody] ProductCharacteristicChangeSetting updatedCharacteristic)
        {
            if (id == 0)
            {
                ModelState.AddModelError(ErrorResponses.InvalidId, string.Empty);
            }
            if (updatedCharacteristic == null)
            {
                ModelState.AddModelError(ErrorResponses.MissingBody, string.Empty);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var charModel = new ProductCharacteristic()
            {
                Id      = id, Name = updatedCharacteristic.Name, Description = updatedCharacteristic.Description,
                Enabled = updatedCharacteristic.Enabled, Visible = updatedCharacteristic.Visible
            };
            var currentUser = await CurrentUserRetriever.GetCurrentUserAsync();

            var updateCharacteristicCommand = new Jibberwock.Persistence.DataAccess.Commands.Products.UpdateCharacteristic(Logger, currentUser, HttpContext.TraceIdentifier, WebApiConfiguration.Authorization.DefaultServiceId, null, charModel);

            var updateSuccessful = await updateCharacteristicCommand.Execute(SqlServerDataSource);

            if (updateSuccessful.Result != null)
            {
                return(Ok(updateSuccessful.Result));
            }
            else
            {
                return(NotFound());
            }
        }
Esempio n. 13
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as NutritionProduct;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.NutritionProduct.NutritionProductStatus>)StatusElement.DeepCopy();
            }
            if (Category != null)
            {
                dest.Category = new List <Hl7.Fhir.Model.CodeableConcept>(Category.DeepCopy());
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
            }
            if (Manufacturer != null)
            {
                dest.Manufacturer = new List <Hl7.Fhir.Model.ResourceReference>(Manufacturer.DeepCopy());
            }
            if (Nutrient != null)
            {
                dest.Nutrient = new List <Hl7.Fhir.Model.NutritionProduct.NutrientComponent>(Nutrient.DeepCopy());
            }
            if (Ingredient != null)
            {
                dest.Ingredient = new List <Hl7.Fhir.Model.NutritionProduct.IngredientComponent>(Ingredient.DeepCopy());
            }
            if (KnownAllergen != null)
            {
                dest.KnownAllergen = new List <Hl7.Fhir.Model.CodeableReference>(KnownAllergen.DeepCopy());
            }
            if (ProductCharacteristic != null)
            {
                dest.ProductCharacteristic = new List <Hl7.Fhir.Model.NutritionProduct.ProductCharacteristicComponent>(ProductCharacteristic.DeepCopy());
            }
            if (Instance != null)
            {
                dest.Instance = (Hl7.Fhir.Model.NutritionProduct.InstanceComponent)Instance.DeepCopy();
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            return(dest);
        }
Esempio n. 14
0
 public DeleteCharacteristic(ILogger logger, User performedBy, string connectionId, long serviceId, string comment, ProductCharacteristic characteristic)
     : base(logger, performedBy, connectionId, serviceId, comment)
 {
     ProductCharacteristic = characteristic;
 }