Ejemplo n.º 1
0
        public FineType Create(FineType fineType)
        {
            var type = _context.FineTypes.Add(fineType).Entity;

            _context.SaveChangesAsync();
            return(type);
        }
Ejemplo n.º 2
0
        private void comboRecordCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            FineType type = FineTypeDataMapper.FindByID((int)comboRecordCategory.SelectedValue);

            boxRecordAmmount.Text = type.MaxFine.ToString();
            boxRecordPoints.Text  = type.PointPenalty.ToString();
        }
Ejemplo n.º 3
0
        public void CreateFineType(FineType fineType)
        {
            try
            {
                if (!String.IsNullOrEmpty(fineType.TypeName))
                {
                    ValidateFineTypeFields(fineType);

                    var fineT = CrudFactory.CreateFineType(fineType);

                    var valueList = new ValueListSelect
                    {
                        IdList      = "FineType",
                        Value       = fineT.IdType.ToString(),
                        Description = fineT.TypeDescription
                    };
                    VLCrud.Create(valueList);
                }
                else
                {
                    throw new BusinessException(53);
                }
            }

            catch (Exception bex)
            {
                ExceptionManager.GetInstance().Process(bex);
            }
        }
Ejemplo n.º 4
0
        public static FineType XMLSelect(int ID)
        {
            FineType obj = new FineType();

            XmlNode     root = xmlDoc.DocumentElement;
            XmlNodeList list = root.SelectNodes("FineType");

            XmlNode objNode = null;

            foreach (XmlNode node in list)
            {
                XmlNodeList childs = node.ChildNodes;

                foreach (XmlNode child in childs)
                {
                    if (child.Name == "ID")
                    {
                        objNode = (child.InnerText == ID.ToString()) ? node : null;
                        break;
                    }
                }

                if (objNode != null)
                {
                    break;
                }
            }

            if (objNode != null)
            {
                obj = XMLMap(objNode);
            }

            return(obj);
        }
Ejemplo n.º 5
0
        public FineType Update(FineType fineTypeUpdate)
        {
            var fineType = _context.FineTypes.Update(fineTypeUpdate).Entity;

            _context.SaveChangesAsync();
            return(fineType);
        }
Ejemplo n.º 6
0
        public static FineType XMLMap(XmlNode node)
        {
            FineType obj = new FineType();

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.Name == "ID")
                {
                    obj.ID = Convert.ToInt32(child.InnerText);
                }
                if (child.Name == "Category")
                {
                    obj.Category = child.InnerText;
                }
                if (child.Name == "Description")
                {
                    obj.Description = child.InnerText;
                }
                if (child.Name == "MaxFine")
                {
                    obj.MaxFine = Convert.ToInt32(child.InnerText);
                }
                if (child.Name == "PointPenalty")
                {
                    obj.PointPenalty = Convert.ToInt32(child.InnerText);
                }
            }
            return(obj);
        }
Ejemplo n.º 7
0
        public BaseEntity BuildObject(Dictionary <string, object> row)
        {
            var Company = new Company
            {
                IdCompany = GetIntValue(row, IDCOMPANY)
            };
            var Terminal = new Terminal
            {
                IdTerminal = GetIntValue(row, IDTERMINAL)
            };
            var FineType = new FineType
            {
                IdType = GetIntValue(row, IDFINETYPE)
            };
            var Fine = new Fine
            {
                IdFine          = GetIntValue(row, IDFINE),
                FineDescription = GetStringValue(row, DESCRIPTION),
                FineDate        = GetDateValue(row, DATE),
                Company         = Company,
                Terminal        = Terminal,
                FType           = FineType
            };

            return(Fine);
        }
Ejemplo n.º 8
0
 public FineType CreateFineType(FineType fineType)
 {
     if (string.IsNullOrEmpty(fineType.Name))
     {
         throw new InvalidDataException("Missing fields");
     }
     return(_fineTypeRepo.Create(fineType));
 }
Ejemplo n.º 9
0
        public FineType UpdatFineType(FineType fineTypeUpdate)
        {
            var fineType = FindFineTypeById(fineTypeUpdate.Id);

            fineType.ListPrice = fineTypeUpdate.ListPrice;
            fineType.Name      = fineTypeUpdate.Name;
            return(fineType);
        }
Ejemplo n.º 10
0
        public ActionResult <FineType> Put(int id, [FromBody] FineType fineType)
        {
            if (id < 0 || id != fineType.Id)
            {
                return(BadRequest("parameter id and fineType id must be a match"));
            }

            return(_fineTypeService.UpdatFineType(fineType));
        }
Ejemplo n.º 11
0
        public void ValidateIsNotExistingType(FineType fineType)
        {
            FineType type = CrudFactory.RetrieveFineTypeByName <FineType>(fineType);

            if (type != null)
            {
                throw new BusinessException(3);
            }
        }
Ejemplo n.º 12
0
        public FineType NewFineType(string name, int listPrice)
        {
            var fineType = new FineType
            {
                ListPrice = listPrice,
                Name      = name,
            };

            return(fineType);
        }
        //[HttpDelete]
        //[Route("api/FineType/DeleteFineType")]
        public IHttpActionResult Delete(FineType fineType)
        {
            apiResp = new ApiResponse
            {
                Message = "Se elimino existosamente"
            };
            var mng = new FineManager();

            mng.DeleteFineType(fineType);
            return(Ok(apiResp));
        }
Ejemplo n.º 14
0
 public ActionResult <FineType> Post([FromBody] FineType fineType)
 {
     try
     {
         return(_fineTypeService.CreateFineType(fineType));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public BaseEntity BuildObject(Dictionary <string, object> row)
        {
            var fineType = new FineType
            {
                IdType          = GetIntValue(row, IDFINETYPE),
                TypeDescription = GetStringValue(row, DESCRIPTION),
                Cost            = GetDoubleValue(row, COST),
                TypeName        = GetStringValue(row, NAME)
            };

            return(fineType);
        }
Ejemplo n.º 16
0
        private static FineType Map(SqlDataReader reader)
        {
            int      i   = 0;
            FineType obj = new FineType();

            obj.ID           = reader.GetInt32(i++);
            obj.Category     = reader.GetString(i++);
            obj.Description  = reader.GetString(i++);
            obj.MaxFine      = reader.GetInt32(i++);
            obj.PointPenalty = reader.GetInt32(i++);
            obj.State        = reader.GetBoolean(i++);

            return(obj);
        }
Ejemplo n.º 17
0
        private bool loadData()
        {
            bool ret = false;

            List <FineType> list = FineTypeDataMapper.FindAll();

            comboRecordCategory.DisplayMember = "Category";
            comboRecordCategory.ValueMember   = "ID";
            comboRecordCategory.DataSource    = list;

            //Vyplnit tabulku
            FineType type = FineTypeDataMapper.FindByID((int)comboRecordCategory.SelectedValue);

            boxRecordAmmount.Text = type.MaxFine.ToString();
            boxRecordPoints.Text  = type.PointPenalty.ToString();

            return(ret);
        }
Ejemplo n.º 18
0
 public void UpdateFinesSettings(FineType fineType)
 {
     try
     {
         CrudFactory.UpdateFinesSettings(fineType);
         var valueList = new ValueListSelect
         {
             IdList      = "FineType",
             Value       = fineType.IdType.ToString(),
             Description = fineType.TypeName
         };
         VLCrud.Update(valueList);
     }
     catch (Exception ex)
     {
         ExceptionManager.GetInstance().Process(ex);
     }
 }
        public IHttpActionResult Post(FineType fineType)
        {
            try
            {
                var mngr = new FineManager();
                mngr.CreateFineType(fineType);

                apiResp = new ApiResponse
                {
                    Message = "El tipo de multa ha sido creado exitosamente"
                };

                return(Ok(apiResp));
            }
            catch (BusinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }
        public IHttpActionResult Put(FineType fineType)
        {
            try
            {
                var mng = new FineManager();
                mng.UpdateFinesSettings(fineType);

                apiResp = new ApiResponse
                {
                    Message = "El tipo de multa ha sido actualizado"
                };

                return(Ok(apiResp));
            }
            catch (BusinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }
Ejemplo n.º 21
0
        public static FineType FindByID(int id)
        {
            FineType obj = null;

            using (SqlConnection connection = new SqlConnection(DBConnector.GetBuilder().ConnectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand(SQL_SELECT_ID, connection);
                command.Parameters.AddWithValue("@id", id);

                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        obj = Map(reader);
                    }
                }
            }
            return(obj);
        }
Ejemplo n.º 22
0
        public void ValidateFineTypeFields(FineType fineType)
        {
            PropertyInfo[] props = fineType.GetType().GetProperties();

            foreach (PropertyInfo p in props)
            {
                object valor = p.GetValue(fineType, null);

                if (valor.GetType() == typeof(string))
                {
                    if (string.IsNullOrEmpty(Convert.ToString(valor)))
                    {
                        throw new BusinessException(1);
                    }
                }
            }

            if (fineType.Cost < 0)
            {
                throw new BusinessException(2);
            }
        }