Exemple #1
0
        public ResultStatus Add(TOURIS_TM_SUB_CATEGORY_PHOTO subCategoryPhoto)
        {
            try
            {
                _ctx.TOURIS_TM_SUB_CATEGORY_PHOTO.Add(subCategoryPhoto);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
        public ResultStatus Add(TOURIS_TM_CONTACT_US contactUs)
        {
            try
            {
                _ctx.TOURIS_TM_CONTACT_US.Add(contactUs);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Exemple #3
0
        public ResultStatus Add(TOURIS_TM_VILLAGE village)
        {
            try
            {
                _ctx.TOURIS_TM_VILLAGE.Add(village);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Exemple #4
0
        public ResultStatus Add(TOURIS_TM_DISTRICT district)
        {
            try
            {
                _ctx.TOURIS_TM_DISTRICT.Add(district);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
        public ResultStatus Add(GEMA_TM_PRICEL_LIST priceList)
        {
            try
            {
                _ctx.GEMA_TM_PRICEL_LIST.Add(priceList);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Exemple #6
0
        public ResultStatus Add(TOURIS_TM_COUNTRY country)
        {
            try
            {
                _ctx.TOURIS_TM_COUNTRY.Add(country);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Exemple #7
0
        public ResultStatus Add(GEMA_TM_SLIDESHOW slideshow)
        {
            try
            {
                _ctx.GEMA_TM_SLIDESHOW.Add(slideshow);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
        public ResultStatus Add(TOURIS_TM_SOSMED sosmed)
        {
            try
            {
                _ctx.TOURIS_TM_SOSMED.Add(sosmed);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
Exemple #9
0
        public ResultStatus Add(TOURIS_TM_MENU menu)
        {
            try
            {
                _ctx.TOURIS_TM_MENU.Add(menu);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
        public ResultStatus Add(GEMA_TM_SUB_CATEGORY subCategory)
        {
            try
            {
                _ctx.GEMA_TM_SUB_CATEGORY.Add(subCategory);
                _ctx.SaveChanges();
                rs.SetSuccessStatus();
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
            }

            return(rs);
        }
 public ActionResult New(Studio studioRequest)
 {
     if (ModelState.IsValid)
     {
         Studio studio = new Studio
         {
             Name         = studioRequest.Name,
             CEO          = studioRequest.CEO,
             FoundingDate = studioRequest.FoundingDate
         };
         db.Studios.Add(studio);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(studioRequest));
 }
Exemple #12
0
        // Main code middleware code.
        public async Task InvokeAsync(HttpContext httpContext, DbCtx ctx)
        {
            string apiKey            = httpContext.Request.Headers["ApiKey"];
            string requestedEndpoint = httpContext.Request.Path;
            DbLog  log = new DbLog(requestedEndpoint);

            // Log the request.
            User user = ctx.Users.Find(apiKey);

            if (user != null)
            {
                // Log request against a registered user.
                user.DbLogs.Add(log);
            }
            else
            {
                // Log request from unrecognised users.
                string guid = Guid.NewGuid().ToString();
                log.Id = "unknown-" + guid;
                ctx.DbLogs.Add(log);
            }
            ctx.SaveChanges();

            await _next(httpContext);
        }
Exemple #13
0
        /// <summary>
        /// 设备的归还
        /// </summary>
        /// <param name="equipmentId"></param>
        /// <returns>
        /// 0 : 指定Id的设备不存在
        /// 1 : 操作成功
        /// -1 : 指定设备未被领用
        /// </returns>
        public int ReturnEquipment(int equipmentId, string adminAccount)
        {
            var equipment = DbCtx.Equipments
                            .FirstOrDefault(e => e.Id == equipmentId);

            if (equipment == null)
            {
                return(0);
            }
            if (equipment.User == null)
            {
                return(-1);
            }
            DbCtx.Histories.Add(new History()
            {
                ReturnDate     = DateTime.Now,
                EquipmentTitle = equipment.Title,
                UserName       = equipment.User.Name,
                AdminAccount   = adminAccount
            });                    //添加归还记录

            equipment.User = null; //删除当前领用用户
            DbCtx.Entry(equipment).State = EntityState.Modified;
            DbCtx.SaveChanges();
            return(1);
        }
Exemple #14
0
        /// <summary>
        /// 添加一个设备
        /// </summary>
        /// <param name="title">设备的标题</param>
        /// <param name="worth">设备的价格</param>
        /// <param name="dateTime">设备的购买日期</param>
        /// <param name="remark">备注</param>
        /// <param name="equipmentTypeId">设备所属小类的Id</param>
        /// <param name="adminId">当前管理员的Id</param>
        /// <returns>
        /// 0 : 输入的设备种类Id不合法,
        /// 1 : 操作成功
        /// </returns>
        public int AddEquipment(string title, double worth, DateTime dateTime, string remark, int equipmentTypeId, int adminId)
        {
            var equipmentType = DbCtx.EquipmentTypes
                                .FirstOrDefault(et => et.Id == equipmentTypeId);

            if (equipmentType == null || equipmentType.Type == 0)
            {
                return(0);
            }
            var admin = DbCtx.Admins
                        .FirstOrDefault(a => a.Id == adminId); //根据adminId得到admin,不能直接传进来admin给这个DbCtx用!!!

            if (admin == null)
            {
                throw new MyException("此处需要有管理操作", -1);
            }
            string logicId = Util.GenerateIntId();

            DbCtx.Equipments.Add(new Equipment()
            {
                LogicId        = logicId,
                Title          = title,
                Worth          = worth,
                PurchasingDate = dateTime,
                Remark         = remark,
                State          = 1, //默认正常
                EquipmentType  = equipmentType,
                User           = null,
                Admin          = admin
            });
            DbCtx.SaveChanges();
            return(1);
        }
 public ActionResult New(Review reviewRequest)
 {
     if (ModelState.IsValid)
     {
         Review review = new Review
         {
             Content     = reviewRequest.Content,
             Rating      = reviewRequest.Rating,
             MovieId     = reviewRequest.MovieId,
             AuthorEmail = reviewRequest.AuthorEmail
         };
         db.Reviews.Add(review);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(reviewRequest));
 }
Exemple #16
0
 public ActionResult New(Genre genreRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Genres.Add(genreRequest);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(genreRequest));
     }
     catch (Exception e)
     {
         return(View(genreRequest));
     }
 }
Exemple #17
0
 public ActionResult New(Utility roomTypeRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Utilities.Add(roomTypeRequest);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(roomTypeRequest));
     }
     catch (Exception e)
     {
         return(View(roomTypeRequest));
     }
 }
Exemple #18
0
 public ActionResult New(Recenzie recenzieRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Recenzie.Add(recenzieRequest);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(recenzieRequest));
     }
     catch (Exception e)
     {
         return(View(recenzieRequest));
     }
 }
        /// <summary>
        /// Given the info record saves it to repository.
        /// </summary>
        /// <param name="info">Record information to save.</param>
        public void Save(ProductInfo info)
        {
            SetupHelpers();
            Product p = Mapper.Map <ProductInfo, Product>(info);

            DbCtx.Products.AddObject(p);
            DbCtx.SaveChanges();
        }
 public ActionResult New(Doctor doctorRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Doctori.Add(doctorRequest);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(doctorRequest));
     }
     catch (Exception e)
     {
         return(View(doctorRequest));
     }
 }
Exemple #21
0
 public ActionResult New(BookType bookTypeRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.BookTypes.Add(bookTypeRequest);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(bookTypeRequest));
     }
     catch (Exception)
     {
         return(View(bookTypeRequest));
     }
 }
Exemple #22
0
 public ActionResult New(Product productRequest)
 {
     try
     {
         productRequest.CategoryList = GetAllCategories();
         if (ModelState.IsValid)
         {
             db.Products.Add(productRequest);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(productRequest));
     }
     catch (Exception)
     {
         return(View(productRequest));
     }
 }
        public ActionResult Edit(int id, Professor professorRequest)
        {
            Professor professor = db.Professors.Find(id);

            if (ModelState.IsValid)
            {
                if (TryUpdateModel(professor))
                {
                    professor.FirstName    = professorRequest.FirstName;
                    professor.LastName     = professorRequest.LastName;
                    professor.GradDidactic = professorRequest.GradDidactic;

                    db.SaveChanges();
                }
                return(RedirectToAction("Details", "Professor", new { id = id }));
            }
            return(View(professorRequest));
        }
        public ActionResult Edit(int id, Student studentRequestt)
        {
            Student student = db.Students.Find(id);

            if (ModelState.IsValid)
            {
                if (TryUpdateModel(student))
                {
                    student.FirstName = studentRequestt.FirstName;
                    student.LastName  = studentRequestt.LastName;
                    student.StudyYear = studentRequestt.StudyYear;

                    db.SaveChanges();
                }
                return(RedirectToAction("Details", "Student", new { id = id }));
            }
            return(View(studentRequestt));
        }
        public void create_pulsetrigger()
        {
            var trigger = new PushTrigger
            {
                Sensors = _ports
            };

            DbCtx.Triggers.Add(trigger);
            DbCtx.SaveChanges();
        }
Exemple #26
0
        public ActionResult New(Book bookRequest)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //bookRequest.Publisher = db.Publishers.FirstOrDefault(p => p.PublisherId.Equals(1));

                    db.Books.Add(bookRequest);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(bookRequest));
            }
            catch (Exception e)
            {
                return(View(bookRequest));
            }
        }
Exemple #27
0
 public ActionResult New(Persone contactRequest)
 {
     ViewBag.RegionList = GetAllRegions();
     ViewBag.GenderList = GetAllGenderTypes();
     try
     {
         if (ModelState.IsValid)
         {
             db.Persones.Add(contactRequest);
             db.SaveChanges();
             return(RedirectToAction("Index", "Room"));
         }
         return(View(contactRequest));
     }
     catch (Exception e)
     {
         return(View(contactRequest));
     }
 }
        public ActionResult New(Filiala filialaRequest)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // filialaRequest.Departamente = db.Departamente.FirstOrDefault(p => p.DepId.Equals(1));

                    db.Filiale.Add(filialaRequest);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(filialaRequest));
            }
            catch (Exception e)
            {
                return(View(filialaRequest));
            }
        }
Exemple #29
0
        public IActionResult DeleteMovie(Guid id)
        {
            // we will first delete favorites and towatch
            List <Favorites> favoritesList = _db.Favorites.Where(x => x.MovieId == id).ToList();
            List <ToWatch>   toWatchList   = _db.ToWatch.Where(x => x.MovieId == id).ToList();

            _db.Favorites.RemoveRange(favoritesList);
            _db.ToWatch.RemoveRange(toWatchList);

            var movie = _db.Movie.Find(id);

            if (movie != null)
            {
                _db.Movie.Remove(movie);
                _db.SaveChanges();
                return(Ok());
            }
            return(NotFound($"Movie with Id: {id} was not found."));
        }
        public void create_varioTrigger()
        {
            var trigger = new VarioTrigger
            {
                Sensors = _ports,
            };

            DbCtx.Triggers.Add(trigger);
            DbCtx.SaveChanges();
        }