示例#1
0
        public IActionResult Post(About data)
        {
            data.isActive = true;
            var createdAbout = service.Add(data);

            return(CreatedAtAction("Get", new { id = createdAbout.Data.Id }, createdAbout));
        }
        public async Task <ActionResult> Add(AboutViewModel model, HttpPostedFileBase PhotoUrl)
        {
            ResponseModel response = new ResponseModel();

            response.RedirectUrl = Request["ReturnUlr"];
            try
            {
                string path = string.Empty;
                if (PhotoUrl != null)
                {
                    path = await SaveImag(PhotoUrl);
                }
                About dbmodel = Mapper.Map <About>(model);
                dbmodel.PhotoUrl = path;
                _aboutService.Add(dbmodel);
                _unitOfWork.Commit();
                response.Success = true;
                response.Msg     = "保存成功!请稍后...";
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Msg     = "保存失败!" + ex.Message;
            }
            return(Json(response));
        }
示例#3
0
        public IActionResult Add(About about)
        {
            var result = aboutManager.Add(about);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
示例#4
0
        public IActionResult Add(About about)
        {
            var result = _aboutService.Add(about);

            if (result.Success)
            {
                return(View(result.Message));
            }
            return(BadRequest(result.Message));
        }
 public ActionResult Create(About about)
 {
     if (ModelState.IsValid)
     {
         aboutservice.Add(about);
         this.uow.SaveChanges();
         return(RedirectToAction("IndexAdmin", "About"));
     }
     return(View(about));
 }
示例#6
0
 public ActionResult Post(About about)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest());
         }
         _context.Add(about);
         return(Ok());
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
 public ActionResult Create([Bind(Include = "Id,Name,Address,Tel")] About about, FormCollection collection)
 {
     if (db.Abouts.Any())
     {
         TempData["message"] = "شما می توانید یک فروشگاه ایجاد کنید";
         TempData["success"] = "false";
         return(Json(new { success = true }));
     }
     if (ModelState.IsValid)
     {
         db.Abouts.Add(about);
         _aboutSrvice.Add(about);
         //db.SaveChanges();
         return(Json(new { success = true }));
     }
     return(PartialView(viewName: "Create", model: about));
 }
 public IActionResult Create(About about)
 {
     if (HttpContext.Session.GetString("Name") == null)
     {
         return(RedirectToAction("Login", "Admin"));
     }
     if (about.Id == 0)
     {
         var kayıt = aboutService.Add(about);
         TempData["Mesaj"] = kayıt.BasariliMi ? "Kayıt Eklendi." : kayıt.Mesaj;
         return(RedirectToAction("Create", "About"));
     }
     else
     {
         var kayıt = aboutService.Get(x => x.Id == about.Id).Data;
         about.imageUrl = kayıt.imageUrl;
         aboutService.Update(about);
         return(RedirectToAction("Index", "About"));
     }
 }
示例#9
0
 public ActionResult AddAbout(About about)
 {
     _aboutService.Add(about);
     return(RedirectToAction("Index"));
 }