Exemplo n.º 1
0
        public ActionResult Create(Supplier supplier)
        {
            //Validiation
            if (!Authorized(RoleType.OrdersWriter)) return Error(Loc.Dic.error_no_permission);
            if (!ModelState.IsValid) return Error(ModelState);

            //Creation
            SuppliersRepository.Messeges createMessege;
            using (SuppliersRepository supplierRep = new SuppliersRepository(CurrentUser.CompanyId)) createMessege = supplierRep.Create(supplier);

            //BackToUI
            if (createMessege == SuppliersRepository.Messeges.CreatedSuccessfully) return RedirectToAction("Index");
            else if (createMessege == SuppliersRepository.Messeges.Error_ExternalIdExist) return Error(Loc.Dic.error_externalIdAlreadyExist);
            return Error(Loc.Dic.error_suppliers_create_error);
        }
Exemplo n.º 2
0
        public JsonResult AjaxCreate(Supplier supplier)
        {
            if (Authorized(RoleType.OrdersWriter))
            {
                supplier.CompanyId = CurrentUser.CompanyId;

                SuppliersRepository.Messeges messege;
                using (SuppliersRepository supplierRep = new SuppliersRepository(CurrentUser.CompanyId)) messege = supplierRep.Create(supplier);

                if (messege == SuppliersRepository.Messeges.CreatedSuccessfully)
                    return Json(new { success = true, message = String.Empty, newSupplierId = supplier.Id.ToString() }, JsonRequestBehavior.AllowGet);
                else
                    return Json(new { success = false, message = Loc.Dic.error_suppliers_create_error }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { success = false, message = Loc.Dic.error_no_permission }, JsonRequestBehavior.AllowGet);
            }
        }
Exemplo n.º 3
0
        public JsonResult AjaxCreate(Supplier supplier)
        {
            if (Authorized(RoleType.OrdersWriter))
            {
                supplier.CompanyId = CurrentUser.CompanyId;

                SuppliersRepository.Messeges messege;
                using (SuppliersRepository supplierRep = new SuppliersRepository(CurrentUser.CompanyId)) messege = supplierRep.Create(supplier);

                if (messege == SuppliersRepository.Messeges.CreatedSuccessfully)
                {
                    return(Json(new { success = true, message = String.Empty, newSupplierId = supplier.Id.ToString() }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = false, message = Loc.Dic.error_suppliers_create_error }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { success = false, message = Loc.Dic.error_no_permission }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(Supplier supplier)
        {
            //Validiation
            if (!Authorized(RoleType.OrdersWriter))
            {
                return(Error(Loc.Dic.error_no_permission));
            }
            if (!ModelState.IsValid)
            {
                return(Error(ModelState));
            }

            //Creation
            SuppliersRepository.Messeges createMessege;
            using (SuppliersRepository supplierRep = new SuppliersRepository(CurrentUser.CompanyId)) createMessege = supplierRep.Create(supplier);

            //BackToUI
            if (createMessege == SuppliersRepository.Messeges.CreatedSuccessfully)
            {
                return(RedirectToAction("Index"));
            }
            else if (createMessege == SuppliersRepository.Messeges.Error_ExternalIdExist)
            {
                return(Error(Loc.Dic.error_externalIdAlreadyExist));
            }
            return(Error(Loc.Dic.error_suppliers_create_error));
        }