コード例 #1
0
        public async Task <ResponceModel> Add([FromBody] RoomType model)
        {
            var identifier = User.Claims.FirstOrDefault(p => p.Type == "id");

            if (identifier == null)
            {
                return(new ResponceModel(401, "FAILED", null, new string[] { "Yetkilendirme Hatası." }));
            }
            try
            {
                var roomType = await roomTypeService.Add(model);

                if (await roomTypeService.SaveChanges())
                {
                    return(new ResponceModel(200, "OK", roomType, null));
                }
                else
                {
                    return(new ResponceModel(404, "FAILD", null, new string[] { "Veri eklenirken sorun oluştu." }));
                }
            }
            catch (Exception ex)
            {
                await _logService.Add(new SystemLog()
                {
                    Content = ex.Message, CreateDate = DateTime.Now, UserId = 0, EntityName = roomTypeService.GetType().Name
                });

                return(new ResponceModel(400, "ERROR", null, new string[] { "Veri eklenirken sorun oluştu." }));
            }
        }
コード例 #2
0
ファイル: RoomTypeController.cs プロジェクト: soncat1/Movie
 public ActionResult Create(RoomType roomType)
 {
     try
     {
         if (ModelState.IsValid)
         {
             roomTypeService.Add(roomType);
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Không thể tạo loại phòng chiếu!");
     }
     return(View(roomType));
 }
コード例 #3
0
 public RoomType Add(RoomType roomType)
 {
     return(Execute(session => RoomTypeService.Add(roomType)));
 }