Exemplo n.º 1
0
        public ActionResult Edit(All_Clients clients, int id)
        {
            Persons client = new Persons();

            client.Code        = clients.Code;
            client.Name        = clients.Name;
            client.FirstName   = clients.FirstName;
            client.SecondName  = clients.SecondName;
            client.NameCompany = clients.NameCompany;
            client.CellPhone   = clients.CellPhone;
            client.Phone       = clients.Phone;
            client.Email       = clients.Email;
            client.Address     = clients.Address;

            int status = clientsB.Update(client, id);

            if (status == 200)
            {
                TempData["message"] = "Update";
                return(Json(new { success = true }));
            }
            else if (status == 400)
            {
                ModelState.AddModelError("Code", "El codigo se está usando actualmente");
                return(View(clients));
            }
            return(View(clients));
        }
Exemplo n.º 2
0
        //Get Client
        public All_Clients GetById(Int64 id)
        {
            All_Clients clients = new All_Clients();

            try
            {
                return(db.View_Client(id));
            }
            catch (Exception)
            {
                return(clients);
            }
        }
Exemplo n.º 3
0
        // GET: api/Client/5
        public IHttpActionResult Get(int id)
        {
            All_Clients clients = null;

            ClientsB clientB = new ClientsB();

            clients = clientB.GetById(id);

            if (clients == null)
            {
                return(Ok(false));
            }

            return(Ok(clients));
        }
Exemplo n.º 4
0
        //Update Client
        public int Update(Persons personClient, Int64 id)
        {
            try
            {
                String code = db.Check_CodePersons(personClient.Code);

                All_Clients client = GetById(id);

                if (code == null || code == client.Code)
                {
                    db.update_Client(personClient, client.IDPerson);
                    return(200);
                }
                else
                {
                    return(400);
                }
            }
            catch (Exception)
            {
                return(500);
            }
        }
Exemplo n.º 5
0
        //Send Email Invoices
        private int sendEmail(Invoices invoices)
        {
            All_Clients client = clients.GetById(Convert.ToInt32(invoices.IdClient));

            if (client.Email != null)
            {
                String credit;

                if (Convert.ToDateTime(invoices.LimitDate).Date == DateTime.Now.Date)
                {
                    credit = "contado,";
                }
                else
                {
                    credit = "credito, con fecha a cancelar el " + Convert.ToDateTime(invoices.LimitDate).ToShortDateString();
                }
                String subject = "Productos Alimenticios Santa Marta Factura: " + invoices.Code;
                String body    = "Factura a " + credit + " realizada el " + DateTime.Now.ToShortDateString() + " con el numero " + invoices.Code + " por un monto de ₡" + invoices.Total;
                int    state   = emails.SendEmail(client.Email, subject, body);
                return(state);
            }
            return(400);
        }
Exemplo n.º 6
0
        // GET: Clients
        public JsonResult GetClient(string id)
        {
            All_Clients client = clientsB.GetById(Convert.ToInt32(id));

            return(Json(client, JsonRequestBehavior.AllowGet));
        }