public static CustomerType FromModel(CustomerTypeModel model)
 {
     return(new CustomerType {
         Id = model.Id,
         Caption = model.Caption
     });
 }
Exemplo n.º 2
0
        public IActionResult Index(CustomerTypeModel customerType)
        {
            int Discount;
            int Pricetotal = Total(customerType.Customer, productList, out Discount);

            return(RedirectToAction("Summation", new { Pricetotal = Pricetotal, Discount = Discount }));
        }
Exemplo n.º 3
0
        public ActionResult Edit(CustomerTypeModel model)
        {
            if (ModelState.IsValid)
            {
                bool has_error = false;

                if (!has_error)
                {
                    try {
                        var type = CustomerTypeModelConverter.FromModel(model);
                        CustomerTypeService.Update(type);
                    }
                    catch (DomainException e) {
                        ModelState.AddModelError("", e);
                        has_error = true;
                    }
                }

                if (!has_error)
                {
                    return(RedirectToAction("List"));
                }
            }
            return(View());
        }
Exemplo n.º 4
0
        // An async method to insert data in the database using Insight.Database
        // We insert a CustomerTypeModel as the parameter for the stored procedure
        public async Task <bool> InsertAsync(CustomerTypeModel model)
        {
            using (var connection = new SqlConnection(_connectionString))
            {
                // we use the 'InsertCustomerType' store procedure from the database
                var result = await connection.ExecuteAsync("InsertCustomerType", model);

                return(result > 0);
            }
        }
Exemplo n.º 5
0
 public ActionResult DeleteCustmerType(CustomerTypeModel model)
 {
     if (ModelState.IsValid)
     {
         _details = new MasterModel();
         Enums.CrudStatus status = _details.SetCustomerType(model, Enums.CrudType.Delete);
         ReturnAlertMessage(status);
     }
     return(View("AddCustmerType"));
 }
Exemplo n.º 6
0
        public virtual ActionResult Modify(CustomerTypeModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = model.CreateEntity(SaveType.Modify);
            var result = new Dictionary <string, object>();
            var rev    = this.SaveEntity(entity);
            var mess   = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
Exemplo n.º 7
0
        public virtual ActionResult Get(long id)
        {
            var entity = this.GetEntity <CustomerTypeEntity>(id);

            if (entity == null)
            {
                return(null);
            }
            var model = new CustomerTypeModel
            {
                Id   = entity.Id.ToString(),
                Name = entity.Name
            };

            return(this.Jsonp(model));
        }
Exemplo n.º 8
0
        public ActionResult Create(CustomerTypeModel model)
        {
            bool has_error = false;

            if (ModelState.IsValid)
            {
                try {
                    CustomerTypeService.Create(model.Caption);
                }
                catch (DomainException e) {
                    ModelState.AddModelError("", e);
                    has_error = true;
                }
            }

            if (!has_error)
            {
                return(RedirectToAction("List"));
            }

            return(View("Edit"));
        }
Exemplo n.º 9
0
        public virtual ActionResult Add(CustomerTypeModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = model.CreateEntity(SaveType.Add);

            entity.Sequence = GetSequence();
            var result = new Dictionary <string, object>();

            entity.Crm = new CrmEntity {
                Id = CrmId
            };
            var rev  = this.SaveEntity(entity);
            var mess = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Id", entity.Id);
            result.Add("Message", mess);
            result.Add("Sequence", entity.Sequence);
            return(this.Jsonp(result));
        }
 public CustomerTypeSelectedEventArgs(CustomerTypeModel model)
 {
     this.model = model;
 }
Exemplo n.º 11
0
 public Task <bool> InsertAsync(CustomerTypeModel model)
 {
     return(_repository.InsertAsync(model));
 }