Exemplo n.º 1
0
        public ActionResult Create(BuLevelModel BuLevel)
        {
            try
            {
                LoadBusinessUnitItems();

                if (ModelState.IsValid)
                {
                    if (BuLevelService.Exists(BuLevel.ItemName))
                    {
                        DisplayWarningMessage($"The Level Name '{BuLevel.ItemName}' is duplicate");
                        return(View(BuLevel));
                    }
                    BuLevelDto BuLevelModel = Mapper.Map <BuLevelModel, BuLevelDto>(BuLevel);
                    BuLevelService.Add(BuLevelModel);
                    DisplaySuccessMessage($"New BU Level '{BuLevel.ItemName}' has been stored successfully");
                    return(RedirectToAction("List"));
                }
            }
            catch (Exception exp)
            {
                DisplayLoadErrorMessage(exp);
            }
            return(View(BuLevel));
        }
Exemplo n.º 2
0
        // GET: BuLevel/Edit/5
        public ActionResult Edit(int?id)
        {
            BuLevelModel BuLevel = new BuLevelModel();

            LoadBusinessUnitItems();

            try
            {
                if (!id.HasValue)
                {
                    DisplayWarningMessage("Looks like, the ID is missing in your request");
                    return(RedirectToAction("List"));
                }

                if (!BuLevelService.Exists(id.Value))
                {
                    DisplayWarningMessage($"Sorry, We couldn't find the Level with ID: {id.Value}");
                    return(RedirectToAction("List"));
                }

                BuLevelDto BuLevelDto = BuLevelService.GetlevelItem(id.Value);
                BuLevel = Mapper.Map <BuLevelDto, BuLevelModel>(BuLevelDto);
            }
            catch (Exception exp)
            {
                DisplayReadErrorMessage(exp);
            }

            return(View(BuLevel));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id, BuLevelModel BuLevel)
        {
            try
            {
                LoadBusinessUnitItems();

                if (ModelState.IsValid)
                {
                    if (BuLevelService.Exists(BuLevel.ItemName, BuLevel.ItemEntryID))
                    {
                        DisplayWarningMessage($"Level Name '{BuLevel.ItemName}' is duplicate");
                        return(View(BuLevel));
                    }

                    BuLevelDto BuLevelModel = Mapper.Map <BuLevelModel, BuLevelDto>(BuLevel);
                    BuLevelService.Update(BuLevelModel);
                    DisplaySuccessMessage($"BU Level '{BuLevel.ItemName}' details have been modified successfully");
                    return(RedirectToAction("List"));
                }
            }
            catch (Exception exp)
            {
                DisplayUpdateErrorMessage(exp);
            }
            return(View(BuLevel));
        }
 private void MigrateEntity(BuLevelDto sourceEntity, BuLevel targetEntity)
 {
     targetEntity.BusinessUnitID = sourceEntity.BusinessUnitID;
     targetEntity.ItemEntryID    = sourceEntity.ItemEntryID;
     targetEntity.ItemName       = sourceEntity.ItemName;
     targetEntity.UpdateTimeStamp(sourceEntity.LoggedInUserName);
 }
        public void Add(BuLevelDto entity)
        {
            BuLevel ResourceLevel = CreateBusinessEntity(entity, true);

            Entities.Add(ResourceLevel);
            DataContext.Entry(ResourceLevel).State = EntityState.Added;
            DataContext.SaveChanges();
        }
        public void Delete(BuLevelDto entity)
        {
            BuLevel buzEntity = Entities.FirstOrDefault(e => e.ItemEntryID == entity.ItemEntryID);

            buzEntity.IsDeleted = true;
            buzEntity.UpdateTimeStamp(entity.LoggedInUserName);
            Entities.Add(buzEntity);
            DataContext.Entry(buzEntity).State = EntityState.Modified;
            DataContext.SaveChanges();
        }
        private BuLevel CreateBusinessEntity(BuLevelDto categoryDto, bool isNewEntity = false)
        {
            BuLevel ResourceLevel = new BuLevel
            {
                BusinessUnitID = categoryDto.BusinessUnitID,
                ItemName       = categoryDto.ItemName,
                ItemEntryID    = categoryDto.ItemEntryID,
            };

            ResourceLevel.UpdateTimeStamp(categoryDto.LoggedInUserName, true);

            return(ResourceLevel);
        }
Exemplo n.º 8
0
 public void Update(BuLevelDto levelItem)
 {
     repo.Update(levelItem);
 }
Exemplo n.º 9
0
 public void Delete(BuLevelDto levelItem)
 {
     repo.Delete(levelItem);
 }
Exemplo n.º 10
0
 public void Add(BuLevelDto levelItem)
 {
     repo.Add(levelItem);
 }