public CoreCompany Get(int id)
        {
            Companies   ObjCompanies   = new Companies();
            CoreCompany ObjCoreCompany = ObjCompanies.GetCompany(id);

            return(ObjCoreCompany);
        }
Exemple #2
0
        /// <summary>
        /// This private method get and return a CoreCompany Object by Id
        /// </summary>
        /// <param name="id">This is the primary key of record on Table</param>
        /// <returns>CoreCompany Object</returns>
        private CoreCompany GetCompanyInner(int id)
        {
            CoreCompany ObjCoreCompany = this._context.CoreCompanies
                                         .Where(r => r.Id == id)
                                         .FirstOrDefault();

            return(ObjCoreCompany);
        }
Exemple #3
0
 /// <summary>
 /// This private method delete record from table
 /// </summary>
 /// <returns>Bool value as result of transaction</returns>
 private bool DeleteCompanyInner()
 {
     try
     {
         CoreCompany ObjCoreCompany = this._context.CoreCompanies
                                      .Where(r => r.Id == this._id)
                                      .FirstOrDefault();
         this._context.CoreCompanies.Remove(ObjCoreCompany);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public ResponseApi Put(int id, [FromBody] CoreCompany FormData)
        {
            bool        resultTransaction = new Companies().UpdateCompany(id, FormData.Identification, FormData.Name);
            ResponseApi ObjResponseApi    = new ResponseApi();

            ObjResponseApi.Result = resultTransaction;
            if (resultTransaction)
            {
                ObjResponseApi.Message = "The company was updated!";
            }
            else
            {
                ObjResponseApi.Message = "Error, try again.";
            }
            return(ObjResponseApi);
        }
Exemple #5
0
 /// <summary>
 /// This public method add new record in database from parameters method
 /// </summary>
 /// <param name="identification">Identification of company, as NIT in Colombia</param>
 /// <param name="name">Name of company</param>
 /// <returns>Bool value as result of transaction</returns>
 private bool AddCompanyInner(string identification, string name)
 {
     try
     {
         CoreCompany ObjCoreCompany = new CoreCompany();
         ObjCoreCompany.Identification = identification;
         ObjCoreCompany.Name           = name;
         ObjCoreCompany.CreatedAt      = DateTime.Now;
         this.AddInner(ObjCoreCompany);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #6
0
 /// <summary>
 /// This private method updated a record in table
 /// </summary>
 /// <returns>Bool value as result of transaction</returns>
 private bool UpdateCompanyInner()
 {
     try
     {
         CoreCompany ObjCoreCompany = this._context.CoreCompanies
                                      .Where(r => r.Id == this._id)
                                      .FirstOrDefault();
         ObjCoreCompany.Identification = this._identificacion;
         ObjCoreCompany.Name           = this._name;
         this._context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #7
0
 /// <summary>
 /// This private method execute add trigger on db context
 /// </summary>
 /// <param name="ObjCoreCompany">Object to add</param>
 private void AddInner(CoreCompany ObjCoreCompany)
 {
     this._context.CoreCompanies.Add(ObjCoreCompany);
     this._context.SaveChanges();
 }