Exemple #1
0
 public ContractorPresentationStub(contractor dbItem)
 {
     this.Id = dbItem.id;
     this.Name = dbItem.name;
     this.Deleted = dbItem.deleted;
     this.ContractorType = dbItem.contractor_type;
 }
Exemple #2
0
        public ActionResult Create(ContractorFormStub model)
        {
            //bool isNameExist = RepoContractor.Find().Where(p => p.name == model.Name).Count() > 0;

            if (ModelState.IsValid)
            {
                contractor dbItem = new contractor();
                dbItem = model.GetDbObject(dbItem);

                try
                {
                    RepoContractor.Save(dbItem);
                }
                catch (Exception e)
                {
                    return View("Form", model);
                }

                //message
                string template = HttpContext.GetGlobalResourceObject("MyGlobalMessage", "CreateSuccess").ToString();
                this.SetMessage(model.Name, template);

                return RedirectToAction("Index");
            }
            else
            {
                return View("Form", model);
            }
        }
Exemple #3
0
 public contractor GetDbObject(contractor dbItem)
 {
     dbItem.id = this.Id;
     dbItem.name = this.Name;
     dbItem.deleted = this.Deleted;
     dbItem.contractor_type = this.ContractorType;
     return dbItem;
 }
Exemple #4
0
 public ContractorFormStub(contractor dbItem)
     : this()
 {
     this.Id = dbItem.id;
     this.Name = dbItem.name;
     this.Deleted = dbItem.deleted;
     this.ContractorType = dbItem.contractor_type;
 }
Exemple #5
0
 public void Save(contractor dbItem)
 {
     if (dbItem.id == 0) //create
     {
         context.contractors.Add(dbItem);
     }
     else //edit
     {
         var entry = context.Entry(dbItem);
         entry.State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Exemple #6
0
 public void Delete(contractor dbItem)
 {
     context.contractors.Remove(dbItem);
     context.SaveChanges();
 }