Beispiel #1
0
        public ActionResult Create([Bind(Include = "TaxPaerId,FirstName,LastName,UserName,Phone,DepartmentId,MunicipalityId,Address,DocumentTypeId,Document")] TaxPaer taxPaer)
        {
            if (ModelState.IsValid)
            {
                db.TaxPaers.Add(taxPaer);
                try
                {
                    db.SaveChanges();
                    Utilities.CreateUserASP(taxPaer.UserName, "TaxPaer");
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, "");
                    ViewBag.DepartmentId = new SelectList(db.Departments,
                                                          "DepartmentId", "Name", taxPaer.DepartmentId);
                    ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes,
                                                            "DocumentTypeId", "Description", taxPaer.DocumentTypeId);
                    ViewBag.MunicipalityId = new SelectList(db.Municipalities
                                                            .Where(m => m.DepartmentId == taxPaer.DepartmentId).OrderBy(m => m.Name),
                                                            "MunicipalityId", "Name", taxPaer.MunicipalityId);
                    return(View(taxPaer));
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId = new SelectList(db.Departments,
                                                  "DepartmentId", "Name", taxPaer.DepartmentId);
            ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes,
                                                    "DocumentTypeId", "Description", taxPaer.DocumentTypeId);
            ViewBag.MunicipalityId = new SelectList(db.Municipalities
                                                    .Where(m => m.DepartmentId == taxPaer.DepartmentId).OrderBy(m => m.Name),
                                                    "MunicipalityId", "Name", taxPaer.MunicipalityId);
            return(View(taxPaer));
        }
Beispiel #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TaxPaer taxPaer = db.TaxPaers.Find(id);

            db.TaxPaers.Remove(taxPaer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        // GET: TaxPaers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TaxPaer taxPaer = db.TaxPaers.Find(id);

            if (taxPaer == null)
            {
                return(HttpNotFound());
            }
            return(View(taxPaer));
        }
        public ActionResult MySettings(TaxPaer view)
        {
            if (ModelState.IsValid)
            {
                db.Entry(view).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null && ex.InnerException.InnerException != null &&
                        ex.InnerException.InnerException.Message.Contains("index"))
                    {
                        ModelState.AddModelError(string.Empty, "There are a record with the same Name.");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }

                    ViewBag.DepartmentId   = new SelectList(db.Departments, "DepartmentId", "Name", view.DepartmentId);
                    ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", view.DocumentTypeId);
                    ViewBag.MunicipalityId = new SelectList(db.Municipalities.Where(m => m.DepartmentId == view.DepartmentId).
                                                            OrderBy(m => m.Name), "MunicipalityId", "Name", view.MunicipalityId);



                    return(View(view));
                }

                ViewBag.DepartmentId   = new SelectList(db.Departments, "DepartmentId", "Name", view.DepartmentId);
                ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", view.DocumentTypeId);
                ViewBag.MunicipalityId = new SelectList(db.Municipalities.Where(m => m.DepartmentId == view.DepartmentId).
                                                        OrderBy(m => m.Name), "MunicipalityId", "Name", view.MunicipalityId);



                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.DepartmentId   = new SelectList(db.Departments, "DepartmentId", "Name", view.DepartmentId);
            ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", view.DocumentTypeId);
            ViewBag.MunicipalityId = new SelectList(db.Municipalities.Where(m => m.DepartmentId == view.DepartmentId).
                                                    OrderBy(m => m.Name), "MunicipalityId", "Name", view.MunicipalityId);



            return(View(view));
        }
Beispiel #5
0
 public ActionResult Edit([Bind(Include = "TaxPaerId,FirstName,LastName,UserName,Phone,DepartmentId,MunicipalityId,Address,DocumentTypeId,Document")] TaxPaer taxPaer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(taxPaer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentId = new SelectList(db.Departments,
                                           "DepartmentId", "Name", taxPaer.DepartmentId);
     ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes,
                                             "DocumentTypeId", "Description", taxPaer.DocumentTypeId);
     ViewBag.MunicipalityId = new SelectList(db.Municipalities
                                             .Where(m => m.DepartmentId == taxPaer.DepartmentId).OrderBy(m => m.Name),
                                             "MunicipalityId", "Name", taxPaer.MunicipalityId);
     return(View(taxPaer));
 }
        // GET: TaxPaers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TaxPaer taxPaer = db.TaxPaers.Find(id);

            if (taxPaer == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DepartmentId   = new SelectList(db.Departments, "DepartmentId", "Name", taxPaer.DepartmentId);
            ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", taxPaer.DocumentTypeId);
            ViewBag.MunicipalityId = new SelectList(db.Municipalities.Where(m => m.DepartmentId == taxPaer.DepartmentId).
                                                    OrderBy(m => m.Name), "MunicipalityId", "Name", taxPaer.MunicipalityId);
            return(View(taxPaer));
        }
        public ActionResult Create([Bind(Include = "TaxPaerId,FirsName,lastName,UserName,Phone,Address,DepartmentId,MunicipalityId,DocumentTypeId,Document")] TaxPaer taxPaer)
        {
            if (ModelState.IsValid)
            {
                db.TaxPaers.Add(taxPaer);

                try
                {
                    db.SaveChanges();

                    Utilities.CeateUserASP(taxPaer.UserName, "TaxPaer");
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null && ex.InnerException.InnerException != null &&
                        ex.InnerException.InnerException.Message.Contains("index"))
                    {
                        ModelState.AddModelError(string.Empty, "Ther are a record with the same description.");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }

                    ViewBag.DepartmentId   = new SelectList(db.Departments, "DepartmentId", "Name", taxPaer.DepartmentId);
                    ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", taxPaer.DocumentTypeId);
                    ViewBag.MunicipalityId = new SelectList(db.Municipalities.Where(m => m.DepartmentId == taxPaer.DepartmentId).
                                                            OrderBy(m => m.Name), "MunicipalityId", "Name", taxPaer.MunicipalityId);
                    return(View(taxPaer));
                }

                ViewBag.DepartmentId   = new SelectList(db.Departments, "DepartmentId", "Name", taxPaer.DepartmentId);
                ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", taxPaer.DocumentTypeId);
                ViewBag.MunicipalityId = new SelectList(db.Municipalities.Where(m => m.DepartmentId == taxPaer.DepartmentId).
                                                        OrderBy(m => m.Name), "MunicipalityId", "Name", taxPaer.MunicipalityId);
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId   = new SelectList(db.Departments, "DepartmentId", "Name", taxPaer.DepartmentId);
            ViewBag.DocumentTypeId = new SelectList(db.DocumentTypes, "DocumentTypeId", "Description", taxPaer.DocumentTypeId);
            ViewBag.MunicipalityId = new SelectList(db.Municipalities.Where(m => m.DepartmentId == taxPaer.DepartmentId).
                                                    OrderBy(m => m.Name), "MunicipalityId", "Name", taxPaer.MunicipalityId);
            return(View(taxPaer));
        }