Ejemplo n.º 1
0
        public ProductBaseDto getRemedyById(int id)
        {
            try
            {
                var            remedy           = dc.ProductBase.Where(o => o.ProductBaseId == id).FirstOrDefault();
                ProductBaseDto result           = new ProductBaseDto();
                ProductImage   tempProductImage = dc.ProductImage.Where(o => o.ProductBaseId == remedy.ProductBaseId).FirstOrDefault();
                if (tempProductImage != null)
                {
                    result.ImageLink = dc.ListingFile.Where(o => o.ListingFileId == tempProductImage.ListingFileId).FirstOrDefault().FilePath.Substring(15);
                }
                result.ProductBaseId = remedy.ProductBaseId;
                result.Name          = remedy.Name;
                result.Information   = remedy.Information;
                result.Formulation   = remedy.Formulation;
                result.Registration  = remedy.Registration;
                result.Concentration = remedy.Concentration;
                result.EntryTypeId   = remedy.EntryTypeId;
                result.BrandId       = remedy.BrandId;
                result.Range         = remedy.Range;

                return(result);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public async Task SendNotifyEnquireRemedy(ProductBaseDto T, string email)
        {
            var message = new TemplatedPostmarkMessage
            {
                To            = email,
                From          = "*****@*****.**",
                TemplateId    = 15937570,
                TemplateModel = new Dictionary <string, object>
                {
                    { "username", email },
                    { "remedyname", T.Name },
                    { "brand", dc.Brand.Where(o => o.BrandId == T.BrandId).First().Name },
                    { "registration", T.Registration },
                    { "formulation", T.Formulation },
                    { "concentration", T.Concentration },
                    { "active", dc.ProductActiveIngredient.Include(o => o.ActiveIngredient).Where(o => o.ProductBaseId == T.ProductBaseId).First().ActiveIngredient.Name },
                    { "enquiredURL", "http://farmboek.dankospark.co.za/details/brand/" + T.BrandId }
                }
            };

            var client     = new PostmarkClient("20222232-ba77-4976-b1c5-921816baa7e2");
            var sendResult = await client.SendMessageAsync(message);

            if (sendResult.Status == PostmarkStatus.Success)
            {
                Console.WriteLine(sendResult.Status);
            }
            else
            {
                Console.WriteLine(sendResult.Status);
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> notifyEnquireForRemedy([FromBody] ProductBaseDto T, string email)
        {
            try
            {
                var user = await _userMgr.FindByNameAsync(email);

                return(Ok(communicationRepository.notifyEnquireRemedy(T, email, user.FirstName, user.LastName, user.IdNumber, user.cellNumber)));
            }catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 4
0
 public bool notifyEnquireRemedy(ProductBaseDto T, string email, string name, string lastname, string idnumber, string cell)
 {
     try
     {
         SendNotifyEnquireRemedy(T, email);
         SendNotifyAdmin("Remedy", T.Name, name, lastname, idnumber, cell, email, dc.Brand.Where(o => o.BrandId == T.BrandId).First().Name, "http://farmboek.dankospark.co.za/details/brand/" + Convert.ToString(T.BrandId));
         return(true);
     }catch (Exception e)
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        ///<inheritdoc/>
        public async Task <int> AddAsync(ProductBaseDto product, CancellationToken cancellationToken)
        {
            if (!await _categoryRepository.IsValidIdAsync(product.CategoryId, cancellationToken))
            {
                throw new NotFoundException("Category", $"id = {product.CategoryId}");
            }

            var productEntity = new ProductEntity
            {
                Name        = product.Name,
                Price       = product.Price,
                Description = product.Description,
                CategoryId  = product.CategoryId
            };
            await _context.Products.AddAsync(productEntity, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            return(productEntity.Id);
        }