Пример #1
0
        public void MoveNextStage(MoveNextStageDto nextStageDto)
        {
            var batch = GetById(nextStageDto.BatchId);

            if (batch.StageId == Stage.POSTURE)
            {
                throw new ApplicationException("El lote ya se encuentra en la ultima etapa de postura");
            }

            var currentStage = batch.StageId;
            var nextStage    = Stage.NextStageId(batch.StageId);

            var stageChange = new StageChange();

            stageChange.BatchId          = batch.Id;
            stageChange.StageFromId      = currentStage;
            stageChange.StageToId        = nextStage;
            stageChange.CurrentFoodStock = nextStageDto.CurrentFoodStock;

            stageChange.FoodEntryDuringPeriod = GetCurrentStageFoodEntry(batch.Id, nextStageDto.NextStageStartDate, nextStage);
            stageChange.StageFromInitialBirds = GetInitialBirds(batch.Id, currentStage);
            stageChange.StageFromIFinalBirds  = GetBirdsAmount(batch.Id, nextStageDto.NextStageStartDate);

            Uow.StageChanges.Add(stageChange);

            batch.StageId = nextStage;

            if (nextStage == Stage.REBREEDING)
            {
                batch.ReBreedingDate = nextStageDto.NextStageStartDate;
            }
            else if (nextStage == Stage.POSTURE)
            {
                batch.PostureDate = nextStageDto.NextStageStartDate;
            }

            Uow.Batches.Edit(batch);

            foreach (var barn in nextStageDto.BarnsAssigned)
            {
                Uow.BatchBarns.Add(new BatchBarn()
                {
                    BatchId      = batch.Id,
                    BarnId       = barn.BarnId,
                    InitialBirds = (int)barn.InitialBirds
                });
            }

            Uow.Commit();
        }
Пример #2
0
        public ActionResult Editar(Marca marca)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(marca));
            }

            Uow.Marcas.Modificar(marca);
            Uow.Commit();
            return(new JsonResult()
            {
                Data = new { exito = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #3
0
        public void Create(Card card)
        {
            var beneficiary = Uow.Beneficiaries.Get(b => b.Id == card.BeneficiaryId, b => b.Cards);
            var cardNumber  = GenerateNumber(beneficiary);

            foreach (var active in beneficiary.Cards.Where(c => c.EndDate == null))
            {
                active.EndDate = DateTime.Now;
                Uow.Cards.Edit(active);
            }
            card.IssueDate = _clock.Now;
            card.Number    = cardNumber;
            Uow.Cards.Add(card);
            Uow.Commit();
        }
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            var esValido = this.ValidarForm();

            if (!esValido)
            {
                this.DialogResult = DialogResult.None;
            }
            else
            {
                var sucursal = ObtenerEntidadDesdeForm();
                Uow.Sucursales.Modificar(sucursal);
                Uow.Commit();
            }
        }
Пример #5
0
        public ActionResult Editar(ExcepcionModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.CierresCaja = ListadoCierres(model.MaxikioscoId, model.Fecha);
                return(PartialView(model));
            }

            Uow.Excepciones.Modificar(model.Excepcion);
            Uow.Commit();
            return(new JsonResult()
            {
                Data = new { exito = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #6
0
        public ActionResult Eliminar(CategoriaCosto categoriaCosto)
        {
            var hijas = Uow.CategoriasCostos.Listado().Where(x => !x.Eliminado && x.PadreId == categoriaCosto.CategoriaCostoId).ToList();

            foreach (var hija in hijas)
            {
                Uow.CategoriasCostos.Eliminar(hija);
            }
            Uow.CategoriasCostos.Eliminar(categoriaCosto);
            Uow.Commit();
            return(new JsonResult()
            {
                Data = new { exito = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #7
0
        public ActionResult Editar(Entidades.MaxiKiosco maxikiosco)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(maxikiosco));
            }

            ActualizarTurnos(maxikiosco);

            maxikiosco.Desincronizado = true;
            Uow.MaxiKioscos.Modificar(maxikiosco);
            Uow.Commit();

            return(Json(new { exito = true }));
        }
Пример #8
0
        public ActionResult Crear(Proveedor proveedor)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView());
            }

            proveedor.Identifier     = Guid.NewGuid();
            proveedor.CuentaId       = 1;
            proveedor.Desincronizado = true;
            Uow.Proveedores.Agregar(proveedor);
            Uow.Commit();

            return(PartialView());
        }
Пример #9
0
        private void BtnEliminar_Click(object sender, EventArgs e)
        {
            var autor = Uow.Autores.Obtener(a => a.Id == _autorId);

            var titulos = Uow.Titulos.Listado().Where(t => t.AutorId == autor.Id).ToList();

            if (titulos.Any())
            {
                _messageBoxDisplayService.Show(Resources.ErrorMessageEditorialConTitulos, Resources.LabelAutores);
                return;
            }

            Uow.Autores.Eliminar(autor);
            Uow.Commit();
        }
Пример #10
0
        private void BtnEliminar_Click(object sender, EventArgs e)
        {
            var subTema = Uow.SubTemas.Obtener(st => st.Id == _subTemaId);

            var titulos = Uow.Titulos.Listado().Where(t => t.SubtemaId == _subTemaId).ToList();

            if (titulos.Any())
            {
                _messageBoxDisplayService.Show(Resources.ErrorMessageSubTemasConTitulos, Resources.LabelSubTemas);
                return;
            }

            Uow.SubTemas.Eliminar(subTema);
            Uow.Commit();
        }
Пример #11
0
        public ActionResult Edit(Artist EditEntity, int id, SEO POSTSEO, int SEOID = 0)
        {
            if (ModelState.IsValid)
            {
                var Entity = Uow.ArtistRepository.GetByID(id);

                UpdateModel(Entity);

                Uow.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(EditEntity));
        }
Пример #12
0
        public ActionResult Eliminar(int id, FormCollection collection)
        {
            Entidades.MaxiKiosco maxikiosco = Uow.MaxiKioscos
                                              .Obtener(m => m.MaxiKioscoId == id);

            if (maxikiosco == null)
            {
                return(HttpNotFound());
            }

            Uow.MaxiKioscos.Eliminar(maxikiosco);
            Uow.Commit();

            return(Json(new { exito = true }));
        }
Пример #13
0
        public HttpResponseMessage Delete(int id)
        {
            //Get all the activities from the plan
            var activities = Uow.Activities.GetByPlanId(id);

            foreach (var activity in activities)
            {
                Uow.Activities.Delete(activity.Id);
            }

            Uow.Plans.Delete(id);

            Uow.Commit();
            return(new HttpResponseMessage(HttpStatusCode.NoContent));
        }
Пример #14
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            var operador = this.ObtenerOperadorAdministrador();

            if (operador == null)
            {
                return;
            }

            _operadorIdAutoriza = !this.EsOperadorAdmin ? (Guid?)operador.Id : null;

            _venta.OperadorAutoriza = _operadorIdAutoriza;

            if (RbtnCredito.IsChecked)
            {
                GenerarClienteMontoFavor();



                ActualizarVentasDetalle(_notaCreditoId);

                Uow.Commit();

                _messageBoxDisplayService.ShowSuccess("Devolución generada con éxito");

                var crearComprobante = FormFactory.Create <FrmComprobante>();
                crearComprobante._concepto  = "Crédito por devolución";
                crearComprobante._LCN       = _lcn;
                crearComprobante._formaPago = FormaPagoDescripcion();

                var conv = new Conversion();
                crearComprobante._montoTexto = conv.enletras(Total.ToString());

                crearComprobante.Show();
            }

            if (RbtnEgreso.IsChecked)
            {
                //Guardar Gasto??
                ActualizarVentasDetalle(null);

                ActualizarCaja();

                Uow.Commit();

                _messageBoxDisplayService.ShowSuccess("Devolución generada con éxito");
            }
        }
Пример #15
0
        public ActionResult Eliminar(Rubro rubro)
        {
            var productos = Uow.Productos.Listado().Where(p => p.RubroId == rubro.RubroId).ToList();

            if (productos.Count > 0)
            {
                ModelState.AddModelError("ProductosAsociados", "No puede elimiarse el rubro porque tiene productos asociados");
                return(PartialView(rubro));
            }
            Uow.Rubros.Eliminar(rubro);
            Uow.Commit();
            return(new JsonResult()
            {
                Data = new { exito = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #16
0
        public ActionResult Edit(Page EditEntity, int id, SEO POSTSEO, HttpPostedFileBase[] SEOfile, int SEOID = 0)
        {
            if (ModelState.IsValid)
            {
                var Entity = Uow.PagesRepository.GetByID(id);
                UpdateModel(Entity);

                UpsertSEO(Entity, SEOID, POSTSEO, SEOfile, "Pages");

                Uow.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(EditEntity));
        }
Пример #17
0
        public ActionResult Create(Page Entity, SEO SEOEntity, HttpPostedFileBase[] SEOfile)
        {
            if (ModelState.IsValid)
            {
                UpsertSEO(Entity, 0, SEOEntity, SEOfile, "Pages");

                Entity.Date_Creation = DateTime.Now;
                Uow.PagesRepository.Add(Entity);

                Uow.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(Entity));
        }
Пример #18
0
        public void Create(IList <SectionItem> sectionItems)
        {
            if (!sectionItems.Any())
            {
                return;
            }

            var section      = _sectionService.GetById(sectionItems.First().SectionId);
            var currentItems = GetBySectionId(sectionItems.First().SectionId);

            foreach (var sectionItem in sectionItems)
            {
                CreateInternal(sectionItem);
            }
            Uow.Commit();
        }
Пример #19
0
        public void Deveria_Persistir_Presencas_SQL_Test()
        {
            var aluno = AlunoRepository.GetById(1);

            var aula = AulaRepository.GetById(1);

            var presenca = ObjectBuilder.CreatePresenca(aluno, aula, "C");

            PresencaRepository.Add(presenca);

            Uow.Commit();

            var presencas = PresencaRepository.GetAll();

            Assert.AreEqual(2, presencas.Count);
        }
Пример #20
0
        public void Deveria_Persistir_Aluno_SQL_Test()
        {
            TurmaRepository.Add(ObjectBuilder.CreateTurma());

            var turmaEncontrada = TurmaRepository.GetById(1);

            var aluno = ObjectBuilder.CreateAluno(turmaEncontrada);

            AlunoRepository.Add(aluno);

            var alunos = AlunoRepository.GetAll();

            Uow.Commit();

            Assert.AreEqual(2, alunos.Count);
        }
Пример #21
0
        public ActionResult Create(News Entity, SEO SEOEntity, HttpPostedFileBase[] SEOfile)
        {
            if (ModelState.IsValid)
            {
                InsertImage(Entity, "UploadedImage", "News");
                UpsertSEO(Entity, 0, SEOEntity, SEOfile, "News");

                Entity.Date_Creation = DateTime.Now;
                Uow.NewsRepository.Add(Entity);

                Uow.Commit();

                return(RedirectToAction("Index"));
            }
            return(View(Entity));
        }
Пример #22
0
        public bool AcusarEstadoConexion(Guid maxikioscoIdentifier, string dateISO)
        {
            //Actualizo el estado de kiosco
            var kiosco = Uow.MaxiKioscos.Obtener(m => m.Identifier == maxikioscoIdentifier);

            kiosco.UltimaConexion = DateHelper.ISOToDate(dateISO).GetValueOrDefault().ToUniversalTime();
            try
            {
                Uow.Commit();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #23
0
        /// <summary>
        /// Actualiza la base de datos principal con la ultima secuencia de exportacion del kiosco
        /// </summary>
        /// <param name="request"></param>
        public void AcusarExportacion(AcusarExportacionRequest request)
        {
            //Actualizo el estado de kiosco
            var kiosco = Uow.MaxiKioscos.Obtener(m => m.Identifier == request.MaxiKioscoIdentifier);

            kiosco.UltimaSecuenciaExportacion = request.UltimaSecuenciaExportacion;
            var fecha = DateHelper.ISOToDate(request.HoraLocalISO);

            kiosco.UltimaSincronizacionExitosa = fecha;
            Uow.Commit();

            Task.Run(() =>
            {
                Uow.Stocks.Actualizar(request.MaxiKioscoIdentifier);
            });
        }
Пример #24
0
        public ActionResult Crear(Rubro rubro)
        {
            if (!ModelState.IsValid || !EsDescripcionValida(rubro.Descripcion))
            {
                return(PartialView(rubro));
            }
            rubro.Identifier = Guid.NewGuid();
            rubro.CuentaId   = UsuarioActual.CuentaId;
            Uow.Rubros.Agregar(rubro);
            Uow.Commit();

            return(new JsonResult()
            {
                Data = new { exito = true, rubro = rubro }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #25
0
        private void BtnEliminar_Click(object sender, EventArgs e)
        {
            var editorial = Uow.Editoriales.Obtener(ed => ed.Id == _editorialId);

            var titulos = Uow.Titulos.Listado().Where(t => t.EditorialId == _editorialId).ToList();

            if (titulos.Any())
            {
                _messageBoxDisplayService.Show(Resources.ErrorMessageEditorialConTitulos, Resources.LabelEditoriales);
                return;
            }

            editorial.Activo = false;
            Uow.Editoriales.Modificar(editorial);
            Uow.Commit();
        }
Пример #26
0
        public bool DeleteApplication(Guid appId, string securetyKey, string email)
        {
            //WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
            var userProfile = Uow.UserProfiles.GetById(WebSecurity.GetUserId(email));

            if (_linkCreator.GenerateKey(userProfile.SecuretyKey + email) != securetyKey)
            {
                return(false);
            }

            Uow.UserApplications.Delete(Uow.UserApplications.GetById(appId));

            Uow.Commit();

            return(true);
        }
Пример #27
0
        public void Edit(Provider provider)
        {
            var currentProvider = this.GetById(provider.Id);

            currentProvider.Name      = provider.Name;
            currentProvider.Address   = provider.Address;
            currentProvider.City      = provider.City;
            currentProvider.Referent  = provider.Referent;
            currentProvider.Tel1      = provider.Tel1;
            currentProvider.Tel2      = provider.Tel2;
            currentProvider.CellPhone = provider.CellPhone;
            currentProvider.Email     = provider.Email;

            Uow.Providers.Edit(currentProvider);
            Uow.Commit();
        }
Пример #28
0
        public void Deveria_Adicionar_Grupo_ao_Usuario()
        {
            var newGroup = ObjectBuilder.CreateGroup(false);

            GroupRepository.Add(newGroup);

            Uow.Commit();

            var account = AccountRepository.GetAllIncluding(a => a.Groups).First();;

            AuthorizationService.AddGroupToUser(account.Username, new[] { newGroup.Id });

            var acc = AccountRepository.GetByUserName(account.Username);

            Assert.AreEqual(3, acc.Groups.Count);
        }
Пример #29
0
        public ActionResult Editar(Factura factura)
        {
            if (!ModelState.IsValid)
            {
                LlenarControles();
                return(PartialView(factura));
            }

            Uow.Facturas.Modificar(factura);
            Uow.Commit();

            return(new JsonResult()
            {
                Data = new { exito = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #30
0
        public void Deveria_Editar_Presencas_SQL_Test()
        {
            var presencaEncontrada = PresencaRepository.GetById(1);

            Assert.AreEqual("C", presencaEncontrada.StatusPresenca);

            presencaEncontrada.StatusPresenca = "F";

            PresencaRepository.Update(presencaEncontrada);

            Uow.Commit();

            presencaEncontrada = PresencaRepository.GetById(1);

            Assert.AreEqual("F", presencaEncontrada.StatusPresenca);
        }