Esempio n. 1
0
        public async Task <IActionResult> PutVendorCategory([FromRoute] int id, [FromBody] VendorCategory vendorCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vendorCategory.Id)
            {
                return(BadRequest());
            }

            _context.Entry(vendorCategory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VendorCategoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Edit(int id, [Bind("VendorCategoryId,Name")] VendorCategory vendorCategory)
        {
            if (id != vendorCategory.VendorCategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vendorCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VendorCategoryExists(vendorCategory.VendorCategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendorCategory));
        }
Esempio n. 3
0
        public object Put(VendorCategory model)
        {
            object json;

            try
            {
                model = repository.Update(model);

                json = new
                {
                    total   = 1,
                    data    = model,
                    success = true
                };
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }
Esempio n. 4
0
        public IActionResult Seed()
        {
            VendorCategory vendorCategory = new VendorCategory()
            {
                Name = "Cat 1"
            };
            Vendor vendor = new Vendor()
            {
                VendorName = "Vendor 1"
            };

            _context.Add(vendorCategory);

            vendorCategory = new VendorCategory()
            {
                Name = "Cat 2"
            };
            vendor = new Vendor()
            {
                VendorName = "Vendor 2"
            };
            _context.Add(vendorCategory);
            _context.Add(vendor);

            _context.SaveChanges();
            int id = vendor.VendorID;

            return(Content("seeded"));
        }
 //[ValidateAntiForgeryToken]
 public IActionResult Update(VendorCategory vendorCategory)
 {
     if (ModelState.IsValid)
     {
         _ctx.VendorCategories.Update(vendorCategory);
         _ctx.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(vendorCategory));
 }
        public async Task <IActionResult> Create([Bind("VendorCategoryId,Name")] VendorCategory vendorCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendorCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendorCategory));
        }
Esempio n. 7
0
        public async Task <IActionResult> PostVendorCategory([FromBody] VendorCategory vendorCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.VendorCategories.Add(vendorCategory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVendorCategory", new { id = vendorCategory.Id }, vendorCategory));
        }
        protected async Task <Guid> CreateVendorVideoProductionRule()
        {
            const string vendorName       = "Vendor1_Production_Rule";
            const string audioCategory    = "Video company";
            var          sapVendorCode    = "S_ALR_87012011" + DateTime.Now.Millisecond;
            const string EuropeRegion     = Constants.BudgetRegion.Europe;
            const string contentTypeVideo = Constants.ContentType.Video;
            const string productionType   = Constants.ProductionType.FullProduction;

            var vendor = new Vendor
            {
                Name       = vendorName,
                SapVendor  = sapVendorCode,
                Categories = new List <VendorCategory>()
            };

            var audioVendorCategory = new VendorCategory
            {
                Name             = audioCategory,
                Vendor           = vendor,
                HasDirectPayment = true,
                Currency         = new Currency {
                    Code = "USD", Description = "USD", Symbol = "s"
                },
            };

            var vendorRule1 = new VendorRule
            {
                Rule = GetRule(vendorName, false, EuropeRegion, contentTypeVideo, productionType, 0m,
                               new PgPaymentRuleDefinition
                {
                    DetailedSplit = true,
                    Splits        = new[]
                    {
                        new PgPaymentRuleDefinitionSplit
                        {
                            FASplit       = 1m,
                            FPSplit       = 1m,
                            OESplit       = 0m,
                            CostTotalName = Constants.CostSection.Production
                        }
                    }
                }),
                VendorCategory = audioVendorCategory
            };

            EFContext.VendorRule.Add(vendorRule1);
            await EFContext.SaveChangesAsync();

            return(vendorRule1.VendorCategory.VendorId);
        }
        public async Task <IActionResult> Create([Bind("Id,Image,Title")] VendorCategoryViewModel vendorCategoryViewModel)
        {
            if (ModelState.IsValid)
            {
                string filename = "";
                if (vendorCategoryViewModel.Image != null)
                {
                    filename = Guid.NewGuid().ToString().Substring(4) + vendorCategoryViewModel.Image.FileName;
                    UploadFile(vendorCategoryViewModel.Image, filename);
                }
                VendorCategory vendorCategory = new VendorCategory {
                    Image = filename, MediaType = vendorCategoryViewModel.MediaType, Title = vendorCategoryViewModel.Title
                };
                _context.Add(vendorCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(vendorCategoryViewModel));
        }
Esempio n. 10
0
        public object Delete(VendorCategory model)
        {
            object json;

            try
            {
                bool result = repository.Remove(model);
                json = new
                {
                    success = result
                };
            } catch (Exception ex) {
                json = new
                {
                    success = false,
                    message = ex.Message
                };
            }

            return(json);
        }
        private async Task <Guid?> InitDpvData(
            string sapvendorNumber,
            string vendorName     = "Test vendor 1",
            bool isAipe           = false,
            string budgetRegion   = "AAK (Asia)",
            string contentType    = Constants.ContentType.Video,
            string productionType = Constants.ProductionType.FullProduction,
            string category       = "Production company",
            decimal total         = 0,
            PgPaymentRuleDefinition ruleDefinition = null
            )
        {
            var rule = GetRule(vendorName, isAipe, budgetRegion, contentType, productionType, total, ruleDefinition);

            var vendor = new Vendor
            {
                Name       = vendorName,
                SapVendor  = sapvendorNumber,
                Categories = new List <VendorCategory>()
            };
            var vendorCategory = new VendorCategory
            {
                Name             = category,
                Vendor           = vendor,
                HasDirectPayment = true,
                Currency         = new Currency {
                    Id = usdId, Code = "USD", Description = "USD", Symbol = "s"
                },
            };
            var vendorRule = new VendorRule {
                Rule = rule, VendorCategory = vendorCategory
            };

            EFContext.VendorRule.Add(vendorRule);

            await EFContext.SaveChangesAsync();

            return(vendorRule.VendorCategory.VendorId);
        }
Esempio n. 12
0
        public JsonResult Confirm(ConfirmedTransaction confirmed)
        {
            //Get the transaction from the db
            var transaction = db.Transactions.Find(confirmed.TransactionID);

            //Update the CategoryID and VendorID to match the confirmed transaction
            transaction.VendorID   = confirmed.VendorID;
            transaction.CategoryID = confirmed.CategoryID;

            //Update the status to confirmed
            transaction.StatusID = 1;

            //Save Changes
            if (ModelState.IsValid)
            {
                db.Entry(transaction).State = EntityState.Modified;
                db.SaveChanges();
            }

            //Update the transaction count on the vendor category table or add a new row

            try
            {
                var vc = db.VendorCategory.Find(confirmed.VendorID, confirmed.CategoryID);
                vc.TransactionCount++;
                db.Entry(vc).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch
            {
                var newVC = new VendorCategory(confirmed.VendorID, confirmed.CategoryID, 1);
                db.VendorCategory.Add(newVC);
                db.SaveChanges();
            }

            confirmed.VendorDetected = transaction.VendorDetected;
            confirmed.Description    = transaction.Description;
            return(Json(confirmed));
        }
Esempio n. 13
0
        public async Task <IActionResult> AddCat(EditVendorProfileViewModel model, [FromBody] int [] cat)
        {
            model.CatListing = cat;
            var User = await GetCurrentUserAsync();

            if (ModelState.IsValid)
            {
                foreach (int catid in model.CatListing)
                {
                    VendorCategory vct = (from vc in context.VendorCategory
                                          where vc.CategoryId == catid && vc.VendorUser == User
                                          select vc).SingleOrDefault();

                    if (vct == null)
                    {
                        context.VendorCategory.Add(new VendorCategory {
                            VendorUser = User, CategoryId = catid
                        });
                    }
                }
            }
            try
            {
                await context.SaveChangesAsync();

                return(View());
                //return RedirectToAction("Profile", new RouteValueDictionary(
                //new { controller = "Vendor", action = "Profile"}));
            }

            catch (DbUpdateException)
            {
                return(RedirectToAction("Index", new RouteValueDictionary(
                                            new { controller = "Home", action = "Index" })));
            }
        }
        protected async Task <Guid> CreateVendor()
        {
            const string vendorName     = "Vendor1_MultipleCategories_MultipleRules";
            const string musicCategory  = "Music company";
            const string audioCategory  = "Audio company";
            var          sapVendorCode  = "S_ALR_87012011" + DateTime.Now.Millisecond;
            const string chinaRegion    = Constants.BudgetRegion.China;
            const string europeRegion   = Constants.BudgetRegion.Europe;
            const string contentType1   = Constants.ContentType.Video;
            const string contentType2   = Constants.ContentType.Audio;
            const string productionType = Constants.ProductionType.FullProduction;

            var vendor = new Vendor
            {
                Name       = vendorName,
                SapVendor  = sapVendorCode,
                Categories = new List <VendorCategory>()
            };
            var musicVendorCategory = new VendorCategory
            {
                Name             = musicCategory,
                Vendor           = vendor,
                HasDirectPayment = true,
                Currency         = new Currency {
                    Code = "USD", Description = "USD", Symbol = "s"
                },
            };

            var audioVendorCategory = new VendorCategory
            {
                Name             = audioCategory,
                Vendor           = vendor,
                HasDirectPayment = true
            };

            var vendorRule1 = new VendorRule
            {
                Rule = GetRule(vendorName, false, chinaRegion, contentType1, productionType, 10000m,
                               new PgPaymentRuleDefinition
                {
                    Splits = new[]
                    {
                        new PgPaymentRuleDefinitionSplit
                        {
                            FASplit       = 0.7m,
                            OESplit       = 0.2m,
                            CostTotalName = Constants.CostSection.CostTotal
                        }
                    }
                }),
                VendorCategory = musicVendorCategory
            };
            var vendorRule2 = new VendorRule
            {
                Rule = GetRule(vendorName, false, europeRegion, contentType2, productionType, 10000m,
                               new PgPaymentRuleDefinition
                {
                    Splits = new[]
                    {
                        new PgPaymentRuleDefinitionSplit
                        {
                            FASplit       = 0.7m,
                            OESplit       = 0.4m,
                            CostTotalName = Constants.CostSection.CostTotal
                        }
                    }
                }),
                VendorCategory = audioVendorCategory
            };
            var vendorRule3 = new VendorRule
            {
                Rule = GetRule(vendorName, false, europeRegion, contentType2, productionType, 50000m,
                               new PgPaymentRuleDefinition
                {
                    Splits = new[]
                    {
                        new PgPaymentRuleDefinitionSplit
                        {
                            FASplit       = 0.7m,
                            OESplit       = 0.5m,
                            CostTotalName = Constants.CostSection.CostTotal
                        }
                    }
                }),
                VendorCategory = audioVendorCategory
            };

            var vendorRule4 = new VendorRule
            {
                Rule = GetRule(vendorName, false, europeRegion, contentType2, productionType, 10000m,
                               new PgPaymentRuleDefinition
                {
                    Splits = new[]
                    {
                        new PgPaymentRuleDefinitionSplit
                        {
                            FASplit       = 0.7m,
                            OESplit       = 0.3m,
                            CostTotalName = Constants.CostSection.CostTotal
                        }
                    }
                }),
                VendorCategory = musicVendorCategory
            };

            EFContext.VendorRule.Add(vendorRule1);
            EFContext.VendorRule.Add(vendorRule2);
            EFContext.VendorRule.Add(vendorRule3);
            EFContext.VendorRule.Add(vendorRule4);

            await EFContext.SaveChangesAsync();

            return(vendorRule1.VendorCategory.VendorId);
        }