private AreaDTO Map(tblArea tbl)
 {
     var dto = new AreaDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.Name,
                       Description = tbl.Description,
                       RegionMasterId = tbl.Region
                   };
     return dto;
 }
Example #2
0
        public IActionResult Insertar([FromBody] AreaDTO area)
        {
            if (area == null)
            {
                return(BadRequest("Debe enviar datos"));
            }

            if (string.IsNullOrEmpty(area.Descripcion))
            {
                return(BadRequest("Debe enviar descripciĆ³n"));
            }

            var areaInsertar = _areaService.Insertar(area);

            return(Ok(areaInsertar));
        }
Example #3
0
        public AreaDTO GetAreaDTO(int id)
        {
            AurumData.Area query = new AurumData.Area();
            AreaDTO        B     = new AreaDTO();

            using (var db = new Data())
            {
                query = (from x in db.Areas  where x.Areaid == id select x).FirstOrDefault();
            }
            if (query != null)
            {
                B = new AreaDTO {
                    Areaid = query.Areaid, Descriptor = query.Descriptor, File = query.File, Prefijo = query.Prefijo
                };
            }
            return(B);
        }
        public IActionResult Editar(int id = 0)
        {
            AreaDTO area;

            if (id == 0) //nuevo
            {
                area = new AreaDTO();
            }
            else //editar
            {
                area = _areaService.ObtenerPorId(id);
            }

            ViewBag.listItemsEstados = estado.listItemsEstados;

            return(View(area));
        }
Example #5
0
        public List <AreaDTO> getArea()
        {
            string         sql  = "SELECT * FROM KHUVUC";
            DataTable      data = ConnectionDB.getData(sql);
            List <AreaDTO> list = new List <AreaDTO>();

            for (int i = 0; i < data.Rows.Count; i++)
            {
                AreaDTO area = new AreaDTO();
                area.iMaKV   = data.Rows[i]["MaKV"].ToString();
                area.iTenKV  = data.Rows[i]["TenKV"].ToString();
                area.iGhiChu = data.Rows[i]["GhiChu"].ToString();
                area.iActive = bool.Parse(data.Rows[i]["Active"].ToString());
                list.Add(area);
            }
            return(list);
        }
Example #6
0
        public void Update_With_Correct_Description()
        {
            //Arrange
            var areaDTO = new AreaDTO {
                LayoutId = 5, Description = "test", CoordX = 1, CoordY = 1
            };

            //Act
            service.Create(areaDTO);
            var areaDTOForUpdate = new AreaDTO {
                Id = 1, LayoutId = 5, Description = "update", CoordX = 2, CoordY = 2
            };

            service.Update(areaDTOForUpdate);

            //Assert
            Assert.AreEqual(service.GetById(1).Description, "update");
        }
        private AreaEntryModel GetUpdateStateModel(int areaPK)
        {
            AreaEntryFormData formData     = new AreaEntryFormData();
            List <Control>    formControls = CreateFormControls(areaPK);
            AreaDTO           areaDTO      = areaQuery.GetByPrimaryKey(areaPK);

            if (areaDTO == null)
            {
                throw new KairosException($"Record with primary key '{areaDTO.Area_PK}' is not found.");
            }

            return(new AreaEntryModel()
            {
                FormData = formData,
                FormControls = formControls,
                Model = areaDTO,
            });
        }
Example #8
0
        public async Task <IEnumerable <AreaDTO> > Get()
        {
            var            states  = _BusinessBase.Get();
            List <AreaDTO> Arealst = null;

            if (states != null)
            {
                Arealst = new List <AreaDTO>();
                foreach (var item in states)
                {
                    AreaDTO area = new AreaDTO();
                    area.AreaName = item.AreaName;
                    area.Id       = item.Id;
                    Arealst.Add(area);
                }
            }
            return(Arealst);
        }
Example #9
0
        public async Task <AreaDTO> Put(Guid instanceID, Guid userID, Guid identityWorkID, AreaValidator validator, IMapper mapper,
                                        AreaDTO AreaDTO)
        {
            var mgr   = new MiddlewareManager <Area>(new BaseRecordManager <Area>(), validator);
            var found = (await mgr.FindByExpressionAsync(x => x.ID == AreaDTO.ID, identityWorkID)).FirstOrDefault();

            if (found != null)
            {
                found.Name = AreaDTO.Name;
                await mgr.UpdateAsync(new List <Area>() { found }, identityWorkID);
            }
            else
            {
                return(await Post(instanceID, userID, identityWorkID, validator, mapper, AreaDTO));
            }

            return(AreaDTO);
        }
Example #10
0
        public IEnumerable <AreaDTO> GenerateData(int quantity)
        {
            List <AreaDTO> list = new List <AreaDTO>();

            for (int i = 0; i < quantity; i++)
            {
                AreaDTO data = new AreaDTO()
                {
                    Id         = i,
                    Name       = Faker.Commerce.Department(),
                    CreatedAt  = DateTime.Now,
                    ModifiedAt = DateTime.Now,
                    CreatedBy  = Faker.Name.FirstName(),
                    ModifiedBy = Faker.Name.FirstName()
                };
                list.Add(data);
            }
            return(list.AsEnumerable());
        }
Example #11
0
        public void ParseAreaIdNotZero_Test()
        {
            // Arrange
            AreaDTO areaDTO = new AreaDTO()
            {
                Id          = 3,
                Name        = "Test Area",
                Description = "About"
            };

            // Act
            Area area = factory.Parse(areaDTO);

            // Assert
            Assert.True(area != null &&
                        area.Id == areaDTO.Id &&
                        area.Name == areaDTO.Name &&
                        area.Description == areaDTO.Description);
        }
        public AreaDTO InsertarExecuteSqlCommand(AreaDTO area)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@DESCRIPCION", area.Descripcion),
                    new SqlParameter("@OBSERVACION", area.Observacion),
                    new SqlParameter("@ESTADO",      area.Estado)
                };

                _contexto.Database.ExecuteSqlCommand("NISUSP_AREA_INSERT @DESCRIPCION, @OBSERVACION, @ESTADO", parameters);

                return(area);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #13
0
        public void Try_To_Update_With_Incorrect_Layout()
        {
            //Arrange
            var areaDTO = new AreaDTO {
                LayoutId = 5, Description = "test", CoordX = 1, CoordY = 1
            };
            var areaDTO2 = new AreaDTO {
                LayoutId = 5, Description = "for update", CoordX = 2, CoordY = 2
            };

            //Act
            service.Create(areaDTO);
            service.Create(areaDTO2);
            var incorrectAreaDTOWithIncorrectDescription = service.GetById(2);

            incorrectAreaDTOWithIncorrectDescription.Description = "test";

            //Assert
            Assert.Throws <NotUniqueDescriptionException>(() => service.Update(incorrectAreaDTOWithIncorrectDescription));
        }
        public async Task <IHttpActionResult> GetArea(int ID)
        {
            // Attempting to fetch the Area
            AreaDTO areaDTO = await _DB
                              .Areas
                              .Select(x => new AreaDTO()
            {
                ID   = x.ID,
                Name = x.Name
            }
                                      ).FirstOrDefaultAsync(x => x.ID == ID);

            // If not fetched, return a NotFoundResult
            if (areaDTO == null)
            {
                return(NotFound());
            }

            // Return an OkResult, with the Area
            return(Ok(areaDTO));
        }
Example #15
0
        private void Carga_Busqueda()
        {
            Search_Params Sp = new Search_Params();

            Sp.data       = areaManager.GetAll();
            Sp.palabra    = "";
            Sp.parametros = new List <string>();
            Sp.parametros.Add("Area");

            BusquedaFrm BF = new BusquedaFrm(Sp);

            BF.ShowDialog();
            var seleccion = BF.GetValue();

            if (seleccion > -1)
            {
                currentindex = seleccion;
                currentArea  = areaManager.GetAreaDTO(currentindex);
                DespliegaCampos();
            }
        }
Example #16
0
 public IActionResult Get()
 {
     try
     {
         IEnumerable <Area> areasInBD     = areaLogic.GetAll();
         List <AreaDTO>     areasToReturn = new List <AreaDTO>();
         foreach (Area area in areasInBD)
         {
             AreaDTO areaDTO = new AreaDTO(area);
             areasToReturn.Add(areaDTO);
         }
         return(Ok(areasToReturn));
     }
     catch (BusinessLogicException e)
     {
         return(BadRequest(e.Message));
     }
     catch (DataAccessException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
Example #17
0
        public static Int32 StoreArea(AreaDTO area)
        {
            using (SqlConnection cnn = WordDAC.NewConnection)
                using (SqlCommand cmd = cnn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "[area_pkg.store]";

                    SqlParameter idParam = cmd.Parameters.Add("id", SqlDbType.Int);
                    idParam.Value     = (area.ID.HasValue) ? (object)area.ID.Value : DBNull.Value;
                    idParam.Direction = ParameterDirection.InputOutput;

                    cmd.Parameters.AddWithValue("@title", area.Title);
                    cmd.Parameters.AddWithValue("@company_id", area.CompanyID);
                    cmd.Parameters.AddWithValue("@filter_on_unknown", area.FilterOnUnknown);

                    cnn.Open();
                    cmd.ExecuteNonQuery();

                    return(Convert.ToInt32(idParam.Value));
                }
        }
        public string InsertarExecuteSqlCommandOut(AreaDTO area)
        {
            var msg = "";

            try
            {
                var outRespuesta = new SqlParameter {
                    ParameterName = "@RESPUESTA", SqlDbType = SqlDbType.VarChar, Size = 200, Direction = ParameterDirection.Output
                };

                SqlParameter[] parameters =
                {
                    new SqlParameter("@DESCRIPCION", area.Descripcion)
                    {
                        SqlDbType = SqlDbType.VarChar,Size      = 100, Direction = ParameterDirection.Input
                    },
                    new SqlParameter("@OBSERVACION", area.Observacion)
                    {
                        SqlDbType = SqlDbType.VarChar,Size      = 200, Direction = ParameterDirection.Input
                    },
                    new SqlParameter("@ESTADO",      area.Estado)
                    {
                        SqlDbType = SqlDbType.Bit,   Direction = ParameterDirection.Input
                    },
                    outRespuesta
                };

                _contexto.Database.ExecuteSqlCommand("NISUSP_AREA_INSERT_OUTPUT @DESCRIPCION, @OBSERVACION, @ESTADO, @RESPUESTA OUTPUT", parameters);

                msg = outRespuesta.Value.ToString();
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }

            return(msg);
        }
Example #19
0
        public IActionResult CreateArea([FromForm] AreaDTO area)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var createdArea = _areaRepository.SaveArea(area);

                _areaRepository.InsertLogoURL(area, _areaService.uploadFile(area.Logo));
                _areaRepository.InsertIconURL(area, _areaService.uploadFile(area.Icon));

                return(Ok(createdArea));
            }
            catch (NullReferenceException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #20
0
        private async Task<ImportValidationResultInfo> MapAndValidate(AreaDTO dto, int index)
        {
            return await Task.Run(() =>
                                      {
                                          if (dto == null) return null;
                                          var entity = _mappingService.Map(dto);
                                          var exist =
                                              _ctx.tblArea.FirstOrDefault(p => p.Name.ToLower() == dto.Name.ToLower());

                                          entity.Id = exist == null ? Guid.NewGuid() : exist.id;

                                          var res = _repository.Validate(entity);
                                          var vResult = new ImportValidationResultInfo()
                                                            {
                                                                Results = res.Results,
                                                                Description =
                                                                    string.Format("Row-{0} name or code=>{1}", index,
                                                                                  entity.Name ?? entity.Description),
                                                                Entity = entity
                                                            };
                                          return vResult;

                                      });
        }
Example #21
0
 public bool IsDescriptionUniqueByLayoutId(AreaDTO obj)
 {
     return(areaService.IsDescriptionUniqueByLayoutId(FromAreaDTOToBLLStandardAreaDTO(obj)));
 }
Example #22
0
 public long Insert(AreaDTO entity)
 {
     return(organizationDAO.Insert(new AreaBO(entity)));
 }
Example #23
0
 public Task <AreaDTO> Update(AreaDTO entity)
 {
     throw new System.NotImplementedException();
 }
Example #24
0
 public void Update(AreaDTO item)
 {
     item.TimeStamps = DateTime.Now;
     _unitOfWork.EFRepository <Area>().Update(_mapper.Map <Area>(item));
 }
Example #25
0
 public void InsertArea(AreaDTO area)
 {
     UManager.InsertArea(area);
 }
Example #26
0
 public void EditArea(AreaDTO area)
 {
     UManager.EditArea(area);
 }
Example #27
0
 public Task <AreaDTO> Add(AreaDTO entity)
 {
     throw new NotImplementedException();
 }
Example #28
0
 public void AddArea(AreaDTO area)
 {
     throw new NotImplementedException();
 }
Example #29
0
        public void SeleccionoBarra()
        {
            this.textoBoxp2.Focus();
            if (comandBar1.Status == RecordAction.Search)
            {
                Carga_Busqueda();
            }
            if (comandBar1.Status == RecordAction.None)
            {
                this.panel1.Enabled = false;
            }
            if (comandBar1.Status == RecordAction.Insert || (comandBar1.Status == RecordAction.Update))
            {
                this.panel1.Enabled = true;
                this.panel1.Select();
                if (comandBar1.Status == RecordAction.Insert)
                {
                    initField();
                }
                textoBoxp2.Focus();
            }

            if (comandBar1.Status == RecordAction.Delete && comandBar1.confirma)
            {
                areaManager.Delete(currentArea.Areaid);
                this.comandBar1.confirma = false;
                initField();
                panel1.Enabled = false;
                Utilities.Mensaje(errorBar1, "El registro fue Borrado", errorType.Error);
            }
            if (comandBar1.Status == RecordAction.Save)
            {
                var aux = validaforma();
                if (aux != "")
                {
                    errorBar1.Mensaje = aux;
                    errorBar1.Status  = errorType.Error;
                    this.comandBar1.Novalido();
                    return;
                }
                if (comandBar1.Status == RecordAction.Save && comandBar1.previo == RecordAction.Insert && aux == "")
                {
                    var area = new Area {
                        Descriptor = textoBoxp2.Text, Mesas = Convert.ToInt16(textoBoxp3.Text), Prefijo = textoBoxp1.Text, File = ""
                    };
                    var areaDTO = new AreaDTO {
                        Descriptor = textoBoxp2.Text, Mesas = Convert.ToInt16(textoBoxp3.Text), Prefijo = textoBoxp1.Text, File = ""
                    };
                    var aux1 = validarRegistro(area);
                    if (aux1.Length > 0)
                    {
                        Utilities.Mensaje(errorBar1, aux1, errorType.Error);
                        return;
                    }
                    areaManager.InsertClase(areaDTO);
                    this.comandBar1.previo = RecordAction.None;
                    Utilities.Controles(this, "Reset");
                    panel1.Enabled = false;
                }

                if (comandBar1.Status == RecordAction.Save && comandBar1.previo == RecordAction.Update && aux == "")
                {
                    var area = new Area {
                        Descriptor = textoBoxp2.Text, Mesas = Convert.ToInt16(textoBoxp3.Text), Prefijo = textoBoxp1.Text, File = "", Areaid = Convert.ToInt16(labelindex.Text)
                    };
                    var areaDTO = new AreaDTO {
                        Descriptor = textoBoxp2.Text, Mesas = Convert.ToInt16(textoBoxp3.Text), Prefijo = textoBoxp1.Text, File = "", Areaid = Convert.ToInt16(labelindex.Text)
                    };

                    var aux1 = validarRegistro(area);
                    if (aux1.Length > 0)
                    {
                        Utilities.Mensaje(errorBar1, aux1, errorType.Error);
                        return;
                    }
                    areaManager.Edit(areaDTO);
                    this.comandBar1.previo = RecordAction.None;
                    Utilities.Controles(this, "Reset");
                    panel1.Enabled = false;
                }
            }
        }
Example #30
0
 public void Post([FromBody] AreaDTO value)
 {
     _areaManager.Create(value);
 }
Example #31
0
 public Area Map(AreaDTO dto)
 {
     if (dto == null) return null;
     Area area = Mapper.Map<AreaDTO, Area>(dto);
     area.region = _regionRepository.GetById(dto.RegionMasterId);
     return area;
 }
Example #32
0
 public void Put(string id, [FromBody] AreaDTO value)
 {
     _areaManager.Update(value);
 }
 public IActionResult Get()
 {
     return(Ok(AreaDTO.ToModel(Logic.GetAll())));
 }