Ejemplo n.º 1
0
        public IActionResult EditEntry(string room, int?slot, string day)
        {
            if (String.IsNullOrEmpty(room) || String.IsNullOrEmpty(day) || !slot.HasValue)
            {
                return(RedirectToAction(nameof(Index)));
            }

            EditEntryViewModel editEntry = new EditEntryViewModel();

            editEntry.classesItems  = plannerData.GetClasses();
            editEntry.groupsItems   = plannerData.GetGroups();
            editEntry.teachersItems = plannerData.GetTeachers();

            ActivityData selectedActivity = plannerData.getActivity(room, slot.Value, day);

            if (selectedActivity != null)
            {
                editEntry.clas    = selectedActivity.clas;
                editEntry.group   = selectedActivity.group;
                editEntry.teacher = selectedActivity.teacher;
            }
            else
            {
                editEntry.clas    = "select class";
                editEntry.group   = "select group";
                editEntry.teacher = "select teacher";
            }

            return(View(editEntry));
        }
        public ActionResult Edit(EditEntryViewModel model, HttpPostedFileBase File, int Id)
        {
            if (ModelState.IsValid)
            {
                var entry = Ctx.FormalBlogEntries.FirstOrDefault(b => b.Id == Id);

                var Filestring = FileUpload(File);
                if (Filestring != null)
                {
                    entry.AttachedFile = Filestring;
                }
                else
                {
                    entry.AttachedFile = model.AttachedFile;
                }

                entry.Category = model.Category;


                entry.Content = model.Content;
                entry.Title   = model.Title;

                Ctx.SaveChanges();
            }


            return(RedirectToAction("Index", "FormalBlog"));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteEntry(EditEntryViewModel model)
        {
            var entry = db.YearlyExpenditure.Where(m => m.Id == model.YearId).FirstOrDefault();

            db.YearlyExpenditure.Remove(entry);
            db.SaveChanges();

            return(RedirectToAction("YearlyWageExpenditure"));
        }
        public async Task <IHttpActionResult> EditEntry(EditEntryViewModel model)
        {
            var entry = await db.YearlyExpenditure.Where(m => m.Id == model.YearId).FirstOrDefaultAsync();

            entry.EmployeeName    = model.EmployeeName;
            entry.YearTotal       = model.YearTotal;
            db.Entry(entry).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(Ok("Entry has been updated"));
        }
Ejemplo n.º 5
0
        public ActionResult EditEntry(int yearId)
        {
            var model = new EditEntryViewModel();
            var entry = db.YearlyExpenditure.Where(m => m.Id == yearId).FirstOrDefault();

            model.EmployeeName = entry.EmployeeName;
            model.YearTotal    = entry.YearTotal;
            model.YearId       = yearId;
            return(View(model));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(int id)
        {
            var inventoryEntry = await apiInventoryController.GetByAlbumId(id);

            var editViewModel = new EditEntryViewModel
            {
                Entry      = inventoryEntry,
                AlbumTypes = Enum.GetValues(typeof(AlbumType)).Cast <AlbumType>()
            };

            return(View(editViewModel));
        }
        public IHttpActionResult EditEntry(int yearId)
        {
            var entry = db.YearlyExpenditure.Where(x => x.Id == yearId).FirstOrDefault();
            var model = new EditEntryViewModel()
            {
                EmployeeName = entry.EmployeeName,
                YearId       = entry.Id,
                YearTotal    = entry.YearTotal
            };

            return(Json(model));
        }
Ejemplo n.º 8
0
        public PartialViewResult Edit(int entryId)
        {
            var entry = context.Actions.First(m => m.Id.Equals(entryId));
            var encounter = context.Encounters.First(m => m.FeedEntries.Any(e => e.Id.Equals(entryId)));

            var model = new EditEntryViewModel
            {
                FeedEntry = entry,
                Initiatives = encounter.Initiatives.OrderBy(c => c.Character.Name).ToList()
            };

            return PartialView("~/Views/Encounter/Partials/EditEntry.cshtml", model);
        }
Ejemplo n.º 9
0
        public void ConstructorExtractsCorrectModelData()
        {
            // Arrange
            var todo = new Todo {
                Summary = "summary", Details = "details"
            };
            var entry = new TodoViewModel(todo);

            // Act
            var vm = new EditEntryViewModel(entry);

            // Assert
            Assert.AreEqual("summary", vm.Summary);
            Assert.AreEqual("details", vm.Details);
        }
Ejemplo n.º 10
0
        public IActionResult Edit(string id)
        {
            Entry entry = _repo.GetEntryById(id);

            if (entry != null)
            {
                var vm = new EditEntryViewModel();
                vm.Entry = entry;
                return(View(vm));
            }
            else
            {
                return(Content("Nada"));
            }
        }
Ejemplo n.º 11
0
        public ActionResult EditEntry(EditEntryViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var entry = db.YearlyExpenditure.Where(m => m.Id == model.YearId).FirstOrDefault();

            entry.EmployeeName    = model.EmployeeName;
            entry.YearTotal       = model.YearTotal;
            db.Entry(entry).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("YearlyWageExpenditure"));
        }
Ejemplo n.º 12
0
        public void SaveCommandNeedsSummary()
        {
            // Arrange
            var todo = new Todo {
                Summary = "summary", Details = "details"
            };
            var entry = new TodoViewModel(todo);
            var vm    = new EditEntryViewModel(entry);

            // Act
            bool withSummary = vm.SaveCommand.CanExecute(null);

            vm.Summary = string.Empty;
            bool withoutSummary = vm.SaveCommand.CanExecute(null);

            // Assert
            Assert.IsTrue(withSummary);
            Assert.IsFalse(withoutSummary);
        }
        public ActionResult EditEntry(int EntryId)
        {
            var           BlogEntry        = Ctx.FormalBlogEntries.FirstOrDefault(b => b.Id == EntryId);
            var           CategoryList     = Ctx.Categories.Where(c => c.CategoryType == "Formal").ToList();
            List <string> CategoryListName = new List <string>();

            foreach (var c in CategoryList)
            {
                CategoryListName.Add(c.CategoryName);
            }
            var blogItem1 = new EditEntryViewModel()
            {
                Id            = BlogEntry.Id,
                AttachedFile  = BlogEntry.AttachedFile,
                Category      = BlogEntry.Category,
                Content       = BlogEntry.Content,
                Title         = BlogEntry.Title,
                CategoryItems = CategoryListName
            };

            return(View(blogItem1));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Put(long id, [FromBody] EditEntryViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

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

            var entry = await _entryRepo.GetAsync(id);

            if (entry == null)
            {
                return(NotFound("Entry Not Found!"));
            }

            #region checks

            Guid currencyId;
            var  currency = await _currencyRepo.GetAsync(model.CurrencyId);

            if (currency != null)
            {
                currencyId          = currency.Id;
                model.CurrencyValue = currency.Value;
            }
            else
            {
                currencyId          = _defaultKeysOptions.Value.CurrencyId;
                model.CurrencyValue = 1;
            }


            Guid?costCenterId = null;
            if (model.CostCenterId.HasValue)
            {
                var costCenter = await _costCenterRepo.GetAsync(model.CostCenterId.Value);

                if (costCenter == null)
                {
                    return(NotFound(Resources.CostCenters.CostCenterResource.CostCenterNotFound));
                }
                costCenterId = costCenter.Id;
            }

            Guid?branchId = null;
            if (model.BranchId.HasValue)
            {
                var branch = await _branchRepo.GetAsync(model.BranchId.Value);

                if (branch == null)
                {
                    return(NotFound(Resources.Branchs.BranchResource.BranchNotFound));
                }
                branchId = branch.Id;
            }

            #endregion

            await _accountBalanceService.PostEntryToAccounts(entry, true);

            entry.CurrencyId    = currencyId;
            entry.CurrencyValue = model.CurrencyValue;
            entry.BranchId      = branchId;
            entry.Note          = model.Note;
            entry.Items         = new HashSet <EntryItem>();

            var itemsIndex = 0;
            // check form items if not found
            foreach (var item in model.EntryItems)
            {
                itemsIndex++;

                Guid accountId;
                var  account = await _accountRepo.GetAsync(item.AccountId);

                if (account == null)
                {
                    return(NotFound("account not found"));
                }
                accountId = account.Id;

                Guid itemCurrencyId;
                if (model.CurrencyId == item.CurrencyId)
                {
                    itemCurrencyId     = currencyId;
                    item.CurrencyValue = model.CurrencyValue;
                }
                else
                {
                    var itemCurrency = await _currencyRepo.GetAsync(item.CurrencyId.Value);

                    if (itemCurrency != null)
                    {
                        itemCurrencyId     = itemCurrency.Id;
                        item.CurrencyValue = itemCurrency.Value;
                    }
                }

                Guid?itemCostCenterId = null;
                if (model.CostCenterId.HasValue && item.CostCenterId.HasValue && model.CostCenterId == item.CostCenterId)
                {
                    itemCostCenterId = costCenterId;
                }
                else
                {
                    if (item.CostCenterId.HasValue)
                    {
                        var costCenter = await _costCenterRepo.GetAsync(item.CostCenterId.Value);

                        if (costCenter == null)
                        {
                            return(NotFound(Resources.CostCenters.CostCenterResource.CostCenterNotFound));
                        }
                        itemCostCenterId = costCenter.Id;
                    }
                }

                var entryItem = new EntryItem(accountId, item.Debit, item.Credit, itemCurrencyId, item.CurrencyValue.Value, itemCostCenterId, item.Date.Value.UtcDateTime, item.Note);
                entry.Items.Add(entryItem);
            }

            await _accountBalanceService.PostEntryToAccounts(entry);

            var affectedRows = await _entryRepo.EditAsync(entry);

            if (affectedRows > 0)
            {
                var viewModel = AutoMapper.Mapper.Map <EntryViewModel>(entry);
                return(CreatedAtRoute("GetEntry", new { id = entry.Number }, viewModel));
            }
            return(BadRequest());
        }