Beispiel #1
0
        public static SelectList GetActiveSupplierPlantList()
        {
            IPlantBLL plantBll = MvcApplication.GetInstance <PlantBLL>();
            var       data     = plantBll.GetActivePlant();

            return(new SelectList(data, "WERKS", "DROPDOWNTEXTFIELD"));
        }
        public bool Save(MonthClosingDto item)
        {
            var result = false;

            if (item == null)
            {
                throw new Exception("Invalid Data Entry");
            }

            try
            {
                MONTH_CLOSING model;

                if (item.MonthClosingId > 0)
                {
                    //update
                    model = _repository.Get(c => c.MONTH_CLOSING_ID == item.MonthClosingId).FirstOrDefault();

                    if (model == null)
                    {
                        throw new BLLException(ExceptionCodes.BLLExceptions.DataNotFound);
                    }

                    Mapper.Map <MonthClosingDto, MONTH_CLOSING>(item, model);
                }
                else
                {
                    var activePlant = _plantBll.GetActivePlant();
                    var monthFlag   = item.ClosingDate.ToString("MMyyyy");

                    foreach (var plant in activePlant)
                    {
                        var newData = new MonthClosingDto();
                        newData         = item;
                        newData.PlantId = plant.WERKS;

                        var newModel = new MONTH_CLOSING();
                        newModel            = Mapper.Map <MONTH_CLOSING>(newData);
                        newModel.MONTH_FLAG = monthFlag;
                        newModel.IS_ACTIVE  = true;
                        _repository.InsertOrUpdate(newModel);
                    }
                }

                _uow.SaveChanges();

                result = true;
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return(result);
        }