예제 #1
0
        private static List <BatchViewModel> ProcessFile(DataProcessNumbers dpn, int BatchId, string jsonPath)
        {
            BatchModel            btc     = new BatchModel();
            BatchViewModel        bvm     = new BatchViewModel();
            List <BatchViewModel> bvmList = new List <BatchViewModel>();

            var list = JsonConvert.DeserializeObject <List <BatchViewModel> >(File.ReadAllText(jsonPath));

            bvmList = list ?? bvmList;

            var _batchVM = bvmList.FirstOrDefault(item => item.BatchId == BatchId);

            if (_batchVM != null)
            {
                _batchVM.Batches.Add(btc.ConvertToBatch(dpn));
            }
            else
            {
                bvm.BatchId = BatchId;
                bvm.Batches.Add(btc.ConvertToBatch(dpn));
                bvmList.Add(bvm);
            }


            System.IO.File.WriteAllText(jsonPath, JsonConvert.SerializeObject(bvmList));
            return(bvmList);
        }
예제 #2
0
파일: BatchRepo.cs 프로젝트: sambanf/XBC
        public static ResponResultViewModel Deact(BatchViewModel model)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            using (var db = new MinProContext())
            {
                t_batch batch = db.t_batch.Where(x => x.id == model.id).FirstOrDefault();
                batch.is_delete  = false;
                batch.deleted_by = 1;
                batch.deleted_on = DateTime.Now;
                batch.name       = model.name;

                try
                {
                    db.SaveChanges();
                    result.Entity = model;
                }
                catch (Exception e)
                {
                    result.Success = false;
                    result.Message = e.Message;
                }
            }
            return(result);
        }
예제 #3
0
        public async Task <IActionResult> Create(BatchViewModel batchView, string btnSave)
        {
            if (await _db.Post_GroupMasters.AnyAsync(x => x.GroupName == batchView.GroupName && x.Type == GroupType.Batch))
            {
                ModelState.AddModelError("GroupName", "Batch Name Already Exist");
            }

            if (ModelState.IsValid)
            {
                var newBatch = _mapper.Map <Post_GroupMaster>(batchView);
                newBatch.Type         = GroupType.Batch;
                newBatch.OpenOrClosed = GroupPrivacy.Closed;
                newBatch.GroupImage   = "";
                newBatch.FormedOn     = null;
                var userId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier).Value);
                newBatch.CLogin = userId;
                newBatch.CDate  = DateTime.Now;
                await _db.Post_GroupMasters.AddAsync(newBatch);

                await _db.SaveChangesAsync();

                TempData["message"] = Notifications.SuccessNotify("Batch Created!");
                if (btnSave == "Save")
                {
                    return(RedirectToAction("Index"));
                }
                ModelState.Clear();
                return(View("Create"));
            }

            return(View(batchView));
        }
예제 #4
0
        public virtual ActionResult Batch(string batchId)
        {
            if (string.IsNullOrWhiteSpace(batchId))
            {
                ModelState.AddModelError("batchId", "Batch is required");
                return(RedirectToAction(Actions.Index()));
            }
            var batch = _service.GetBatch(batchId);

            if (batch == null)
            {
                ModelState.AddModelError("batchId", "Batch does not exist.");
                return(RedirectToAction(Actions.Index()));
            }
            var cookie = Request.Cookies[COOKIE_SELECTED_PRINTERS];
            var bucket = _service.GetBucket(batch.BucketId.Value);
            var model  = new BatchViewModel
            {
                BucketId         = bucket.BucketId,
                IsFrozenBucket   = bucket.IsFrozen,
                PrintedBatchList = _service.GetBatches(batch.BucketId.Value).Select(Map).ToArray(),
                PrinterList      = (from printer in _service.GetPrinterList(_buildingId)
                                    select new SelectListItem
                {
                    Text = printer.Description,
                    Value = printer.PrinterName,
                    Selected = cookie != null && cookie.Values[printer.PrinterName] == "Y"
                }).ToArray(),
                BoxList = _service.GetBoxesOfBatch(_buildingId, batchId).Select(Map).ToArray()
            };

            model.CurrentPrintBatch = model.PrintedBatchList.FirstOrDefault(p => p.BatchId == batchId);
            return(View(Views.Batch, model));
        }
예제 #5
0
파일: BatchRepo.cs 프로젝트: sambanf/XBC
        public static BatchViewModel Get(int id)
        {
            BatchViewModel result = new BatchViewModel();

            using (var db = new MinProContext())
            {
                result = (from b in db.t_batch
                          join t in db.t_technology on b.technology_id equals t.id
                          join r in db.t_trainer on b.trainer_id equals r.id
                          join o in db.t_room on b.room_id equals o.id
                          join y in db.t_bootcamp_type on b.bootcamp_type_id equals y.id
                          where b.id == id && b.is_delete == false
                          select new BatchViewModel
                {
                    id = b.id,
                    technology_id = b.technology_id,
                    techname = t.name,
                    name = b.name,
                    trainer_id = b.trainer_id,
                    trainername = r.name,
                    period_from = b.period_from,
                    period_to = b.period_to,
                    room_id = b.room_id,
                    bootcamp_type_id = b.bootcamp_type_id,
                    notes = b.notes,
                    is_delete = b.is_delete
                }).FirstOrDefault();

                //if (result == null)
                //{
                //    result = new CategoryViewModel();
                //}
            }
            return(result);
        }
        public ActionResult GetBatchesForDatatable()
        {
            var batches = _dbContext.Batch.ToList();
            List <BatchViewModel> batchViewModelList = new List <BatchViewModel>();

            foreach (var batch in batches)
            {
                BatchViewModel batchViewModel = new BatchViewModel();
                batchViewModel.Id          = batch.Id;
                batchViewModel.Name        = batch.Name;
                batchViewModel.EnteredDate = batch.EnteredDate;
                batchViewModelList.Add(batchViewModel);
                List <StoreProductsViewModel> storeProductsViewModelList = new List <StoreProductsViewModel>();
                foreach (var storeProduct in batch.StoreProducts)
                {
                    StoreProductsViewModel storeProductsViewModel = new StoreProductsViewModel();
                    storeProductsViewModel.Id          = storeProduct.Id;
                    storeProductsViewModel.ProductName = storeProduct.Product.Name;
                    storeProductsViewModel.Quantity    = storeProduct.Quantity;
                    storeProductsViewModelList.Add(storeProductsViewModel);
                }
                batchViewModel.StoreProductsViewModel = storeProductsViewModelList;
            }

            //     var jsonObject = JsonConvert.SerializeObject(ProductViewModelList);
            // return View();
            var result = new
            {
                iTotalRecords        = batches.Count,
                iTotalDisplayRecords = batches.Count,
                aaData = batchViewModelList
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public async Task EditBatch(BatchViewModel batch)
        {
            Batch existingBatch = applicationDbContext.Batches.FirstOrDefault(b => b.Id == batch.Id);

            existingBatch.Fruit    = batch.Fruit;
            existingBatch.Quantity = batch.Quantity;
            existingBatch.Variety  = batch.Variety;
            try
            {
                await applicationDbContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BatchExists(batch.Id))
                {
                    throw new Exception("Id Exists");
                }
                else
                {
                    throw;
                }
            }

            await UpdateStocks(batch);
        }
예제 #8
0
        public ActionResult Create()
        {
            var organisationId     = UserOrganisationId;
            var centreId           = UserCentreId;
            var trainers           = NidanBusinessService.RetrieveTrainers(organisationId, e => true);
            var courseInstallments = NidanBusinessService.RetrieveCentreCourseInstallments(organisationId, centreId).Items.Select(e => e.CourseInstallment);
            var courses            = NidanBusinessService.RetrieveCourses(organisationId, e => true);
            var rooms     = NidanBusinessService.RetrieveRooms(organisationId, e => e.CentreId == centreId);
            var viewModel = new BatchViewModel()
            {
                Batch    = new Batch(),
                BatchDay = new BatchDay(),
                Course   = new Course()
                {
                    Name = "Test"
                },
                CourseInstallment = new CourseInstallment()
                {
                    Name = "Test"
                },
                Courses            = new SelectList(courses, "CourseId", "Name"),
                Trainers           = new SelectList(trainers, "TrainerId", "Name"),
                Rooms              = new SelectList(rooms, "RoomId", "Description"),
                CourseInstallments = new SelectList(courseInstallments, "CourseInstallmentId", "Name"),
                SelectedTrainerIds = new List <int> {
                }
            };

            viewModel.HoursList              = new SelectList(viewModel.HoursType, "Id", "Name");
            viewModel.MinutesList            = new SelectList(viewModel.MinutesType, "Id", "Name");
            viewModel.NumberOfHoursDailyList = new SelectList(viewModel.NumberOfHoursDailyType, "Id", "Name");
            return(View(viewModel));
        }
예제 #9
0
        public Batches(SmartCoding smartCoding, bool allQueueEmpty)
            : base()
        {
            InitializeComponent();


            this.smartCoding   = smartCoding;
            this.allQueueEmpty = allQueueEmpty;

            this.toolstripChild = this.toolStripChildForm;
            this.fastListIndex  = this.fastBatchIndex;


            this.olvIsDefault.AspectGetter = delegate(object row)
            {// IsDefault indicator column
                if (((BatchIndex)row).IsDefault)
                {
                    return("IsDefault");
                }
                return("");
            };
            this.olvIsDefault.Renderer = new MappedImageRenderer(new Object[] { "IsDefault", Resources.Play_Normal_16 });
            this.buttonApply.Enabled   = allQueueEmpty;

            this.batchAPIs = new BatchAPIs(CommonNinject.Kernel.Get <IBatchAPIRepository>());

            this.batchViewModel = CommonNinject.Kernel.Get <BatchViewModel>();
            this.batchViewModel.PropertyChanged += new PropertyChangedEventHandler(ModelDTO_PropertyChanged);
            this.baseDTO = this.batchViewModel;
        }
예제 #10
0
        //Get By Id
        public static BatchViewModel ById(long id)
        {
            BatchViewModel result = new BatchViewModel();

            using (var db = new XBC_Context())
            {
                result = (from b in db.t_batch
                          join tc in db.t_technology on b.technology_id equals tc.id //into btc
                                                                                     //from tc in btc.DefaultIfEmpty()
                          join tr in db.t_trainer on b.trainer_id equals tr.id       //into btr
                                                                                     //from tr in btr.DefaultIfEmpty()
                          join bt in db.t_bootcamp_type on b.bootcamp_type_id equals bt.id into bbt
                          from bt in bbt.DefaultIfEmpty()
                          join rm in db.t_room on b.room_id equals rm.id into brm
                          from rm in brm.DefaultIfEmpty()
                          where b.id == id && b.is_delete == false
                          select new BatchViewModel
                {
                    id = b.id,
                    technologyName = tc.name,
                    name = b.name,
                    trainerName = tr.name,
                    technologyId = tc.id,
                    periodFrom = b.period_from,
                    bootcampTypeId = bt.id,
                    roomId = rm.id,
                    trainerId = tr.id,
                    periodTo = b.period_to,
                    notes = b.notes
                }).FirstOrDefault();
            }

            return(result == null ? result = new BatchViewModel() : result);
        }
예제 #11
0
        public ActionResult Create()
        {
            var classes   = _classService.GetClasses().ToList();
            var viewModel = new BatchViewModel();

            viewModel.Classes = new SelectList(classes, "ClassId", "Name");
            return(View(viewModel));
        }
예제 #12
0
        public ActionResult Create()
        {
            BatchViewModel vm = new BatchViewModel();

            vm.Organisations = organisationService.GetAllActiveOrganisations();
            vm.Departments   = departmentService.GetAllDepartments();
            vm.Campaigns     = campaignService.GetAllCampaigns();
            return(View(vm));
        }
예제 #13
0
        public MemoryStream SerializeToMemoryStream(BatchViewModel model)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(BatchViewModel));
            MemoryStream  memStream  = new MemoryStream();

            serializer.Serialize(memStream, model);
            memStream.Position = 0;
            return(memStream);
        }
예제 #14
0
        public HttpResponseMessage CreateBatch(BatchViewModel batchViewModel)
        {
            var batch = Mapper.BatchMapper.Attach(batchViewModel);

            _batchService.Add(batch);
            _batchService.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
예제 #15
0
        public ViewResult CreateBatch(int id)
        {
            BatchViewModel bvm = new BatchViewModel
            {
                AcadaProgramId = id,
            };

            return(View(bvm));
        }
예제 #16
0
        public async Task <IActionResult> Create(BatchViewModel batch)
        {
            if (ModelState.IsValid)
            {
                await dataManager.NewBatch(batch);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(batch));
        }
예제 #17
0
        public HttpResponseMessage EditBatch(BatchViewModel batchViewModel)
        {
            //var _batch = _batchService.GetBatchById(batchViewModel.BatchId);
            var batch = Mapper.BatchMapper.Attach(batchViewModel);

            _batchService.Update(batch);
            _batchService.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
예제 #18
0
 public HttpResponseMessage Get(HttpRequestMessage request, int id)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         var batch = _batchesRepository.GetSingle(id);
         BatchViewModel batchVM = Mapper.Map <Batch, BatchViewModel>(batch);
         response = request.CreateResponse <BatchViewModel>(HttpStatusCode.OK, batchVM);
         return response;
     }));
 }
예제 #19
0
        public ActionResult Edit(BatchViewModel model)
        {
            ResponseResult result = BatchRepo.Update(model);

            return(Json(new
            {
                success = result.Success,
                message = result.ErrorMessage,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }
예제 #20
0
        public IActionResult EditSave(BatchViewModel model)
        {
            BatchInformation batchInfo = new BatchInformation
            {
                Id   = model.Id,
                Name = model.Name
            };

            _batchInformationService.UpdateBatchInfo(batchInfo);

            return(RedirectToAction(nameof(Index)));
        }
예제 #21
0
        public ActionResult IndexFullHeight()
        {
            StoreIndexViewModel   storeIndexViewModel = new StoreIndexViewModel();
            List <StoreViewModel> storeViewModelLst   = new List <StoreViewModel>();
            var stores   = db.Stores.ToList();
            var products = db.Products.ToList();

            foreach (var store in stores)
            {
                StoreViewModel storeViewModel = new StoreViewModel();
                storeViewModel.Id   = store.Id;
                storeViewModel.Name = store.Name;
                storeViewModelLst.Add(storeViewModel);
                List <BatchViewModel> batchesViewModelLst = new List <BatchViewModel>();
                foreach (var batch in store.Batches)
                {
                    BatchViewModel batchViewModel = new BatchViewModel();
                    batchViewModel.Id          = batch.Id;
                    batchViewModel.StoreId     = batch.StoreId;
                    batchViewModel.Name        = batch.Name;
                    batchViewModel.EnteredDate = batch.EnteredDate;
                    batchesViewModelLst.Add(batchViewModel);
                    List <StoreProductsViewModel> storeProductsViewModelLst = new List <StoreProductsViewModel>();
                    if (batch.StoreProducts.Count != 0)
                    {
                        foreach (var storeProduct in batch.StoreProducts)
                        {
                            StoreProductsViewModel storeProductsViewModel = new StoreProductsViewModel();
                            storeProductsViewModel.Id               = storeProduct.Id;
                            storeProductsViewModel.BatchId          = storeProduct.BatchId;
                            storeProductsViewModel.ProductId        = storeProduct.ProductId;
                            storeProductsViewModel.ProductEnterDate = storeProduct.ProductEnterDate;
                            Product product = products.Where(p => p.Id == storeProduct.ProductId).FirstOrDefault();
                            storeProductsViewModel.ProductName         = product.Name;
                            storeProductsViewModel.AutoGenerateName    = product.AutoGenerateName;
                            storeProductsViewModel.Code                = product.Code;
                            storeProductsViewModel.ModelNumber         = product.ModelNumber;
                            storeProductsViewModel.MRPPerUnit          = storeProduct.MRPPerUnit;
                            storeProductsViewModel.CostPricePerUnit    = storeProduct.CostPricePerUnit;
                            storeProductsViewModel.DiscountRatePerUnit = storeProduct.DiscountRatePerUnit;
                            storeProductsViewModel.Quantity            = storeProduct.Quantity;
                            storeProductsViewModelLst.Add(storeProductsViewModel);
                            //batchViewModel.StoreProductsViewModel.Add(storeProductsViewModel);
                        }
                    }
                    batchViewModel.StoreProductsViewModel = storeProductsViewModelLst;
                }
                storeViewModel.BatchesViewModel = batchesViewModelLst;
            }
            storeIndexViewModel.StoreViewModel = storeViewModelLst;
            return(View(storeIndexViewModel));
        }
예제 #22
0
        public BatchViewModel GetBatch(int?batchId)
        {
            Batch          batch  = applicationDbContext.Batches.FirstOrDefault(b => b.Id == batchId);
            BatchViewModel result = new BatchViewModel
            {
                Id       = batch.Id,
                Fruit    = batch.Fruit,
                Quantity = batch.Quantity,
                Variety  = batch.Variety,
            };

            return(result);
        }
예제 #23
0
        public ActionResult Update(BatchViewModel model)
        {
            //if (ModelState.IsValid)
            //{
            ResponResultViewModel result = BatchRepo.Update(model);

            return(Json(new
            {
                success = result.Success,
                message = result.Message,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }
예제 #24
0
        // Validalsi Nama Batch Tidak Boleh Sama
        public ActionResult CheckName(string name = "")
        {
            BatchViewModel data   = BatchRepo.CheckName(name);
            ResponseResult result = new ResponseResult();

            if (data.name != null)
            {
                result.Success = false;
            }
            return(Json(new
            {
                success = result.Success
            }, JsonRequestBehavior.AllowGet));
        }
예제 #25
0
        public async Task NewBatch(BatchViewModel batch)
        {
            Batch newBatch = new Batch
            {
                Fruit    = batch.Fruit,
                Quantity = batch.Quantity,
                Variety  = batch.Variety
            };

            applicationDbContext.Batches.Add(newBatch);

            await applicationDbContext.SaveChangesAsync();

            await UpdateStocks(batch);
        }
예제 #26
0
        public IActionResult CreateBatch(BatchViewModel model)
        {
            Batches batches = new Batches()
            {
                AcademyProgramId = model.AcadaProgramId,
                Name             = model.Name,
                Supervisor       = model.Supervisor,
                Year             = model.Year,
                StartDate        = model.StartDate,
                EndDate          = model.EndDate,
            };

            _programmes.AddBatch(batches);
            return(RedirectToAction("listbatch", "studentbatch"));
        }
예제 #27
0
        // GET: Batches/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            BatchViewModel batch = dataManager.GetBatch(id);

            if (batch == null)
            {
                return(NotFound());
            }
            return(View(batch));
        }
예제 #28
0
        public static BatchViewModel Detach(Batch batch)
        {
            BatchViewModel batchviewmodel = new BatchViewModel();

            batchviewmodel.BatchId   = batch.BatchId;
            batchviewmodel.BatchName = batch.BatchName;
            batchviewmodel.CompanyId = batch.CompanyId;
            batchviewmodel.BranchId  = batch.BranchId;
            batchviewmodel.Status    = batch.Status;
            batchviewmodel.CreatedBy = batch.CreatedBy;
            batchviewmodel.CreatedOn = batch.CreatedOn;
            batchviewmodel.UpdatedBy = batch.UpdatedBy;
            batchviewmodel.UpdatedOn = batch.UpdatedOn;
            return(batchviewmodel);
        }
예제 #29
0
        public async Task <IActionResult> Edit(BatchViewModel batch)
        {
            if (batch == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await dataManager.EditBatch(batch);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(batch));
        }
예제 #30
0
        public ActionResult Edit(BatchViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var batch = _repository.Project <Batch, bool>(batches => (from btch in batches where btch.BatchId == viewModel.BatchId select btch).Any());

                if (!batch)
                {
                    _logger.Warn(string.Format("Batch not exists '{0}'.", viewModel.Name));
                    Danger(string.Format("Batch not exists '{0}'.", viewModel.Name));
                    return(RedirectToAction("Edit"));
                }
                if (viewModel.OutTime != null && viewModel.OutTime != null && Convert.ToDateTime(viewModel.InTime).ToShortTimeString() != "12:00 AM" && Convert.ToDateTime(viewModel.OutTime).ToShortTimeString() != "12:00 AM")
                {
                    TimeSpan span = (Convert.ToDateTime(viewModel.OutTime) - Convert.ToDateTime(viewModel.InTime));
                    if (span < TimeSpan.FromHours(1) || span > TimeSpan.FromHours(6))
                    {
                        _logger.Warn(string.Format("The time limit should be min lengh of (1hr) & max length of  (6hrs)", viewModel.Name));
                        Danger(string.Format("The time limit should be min lengh of (1hr) & max length of  (6hrs)", viewModel.Name));
                        return(RedirectToAction("Edit"));
                    }
                }
                var result = _batchService.Update(new Batch {
                    BatchId = viewModel.BatchId, Name = viewModel.Name /*, ClassId = viewModel.ClassId*/, InTime = Convert.ToDateTime(viewModel.InTime), OutTime = Convert.ToDateTime(viewModel.OutTime)
                });
                if (result.Success)
                {
                    Success(result.Results.FirstOrDefault().Message);
                    ModelState.Clear();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    _logger.Warn(result.Results.FirstOrDefault().Message);
                    Warning(result.Results.FirstOrDefault().Message, true);
                }
            }

            ViewBag.SelectedClass = from mt in _classService.GetClasses()
                                    select new SelectListItem
            {
                Value = mt.ClassId.ToString(),
                Text  = mt.Name
            };

            ViewBag.ClassId = viewModel.ClassId;
            return(View(viewModel));
        }