Esempio n. 1
0
 public long Insert(DayOff entity)
 {
     entity.Date = DateTime.Now;
     db.DayOffs.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Esempio n. 2
0
        public void AddStudent(string userId)
        {
            var student = new Student {
                UserId = userId
            };

            db.Students.Add(student);
            db.SaveChanges();
        }
Esempio n. 3
0
        public void RemoveUser(string userId, int eventId, int positionId)
        {
            var remove = this.dbSet.First(u => u.UserId == userId &&
                                          u.PositionId == positionId &&
                                          u.EventId == eventId
                                          );

            this.dbSet.Remove(remove);
            dbContext.SaveChanges();
        }
Esempio n. 4
0
        public long Insert(ViolatorKTV entity)
        {
            int a = 0;

            string[] arrEmpId = string.Join(",", entity.SelectedIDArray).Replace(" ", "").Split(',');
            for (int i = 0; i < arrEmpId.Length; i++)
            {
                entity.Employee_ID = Int32.Parse(arrEmpId[i]);
                entity.TimeOut     = entity.TimeIn.AddHours(12);
                db.ViolatorKTVs.Add(entity);
                db.SaveChanges();
                a = 1;
            }
            return(a);
        }
        public ActionResult Index()
        {
            var callback = string.Format("http://localhost:57498/home/{0}", nameof(Callback));
            var response = clientSubscriber.Subscribe(callback);

            webAppDbContext.Tokens.Add(new Token
            {
                Value   = response.Token,
                Expires = response.Expires
            });

            webAppDbContext.SaveChanges();

            return(View());
        }
Esempio n. 6
0
 public ActionResult Edit(string id, tbl_MCAT tbl_MCAT)
 {
     try
     {
         if (id == null)
         {
             return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         }
         // TODO: Add update logic here
         using (WebAppDbContext db = new WebAppDbContext())
         {
             if (!ModelState.IsValid)
             {
                 return PartialView("_Edit");
             }
             db.Entry(tbl_MCAT).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
         Alert("Record Updated Sucessfully!!!", NotificationType.success);
         return RedirectToAction("Index");
     }
     catch
     {
         Alert("Their is something went wrong!!!", NotificationType.error);
         return RedirectToAction("Index");
     }
 }
Esempio n. 7
0
 public async Task ConfirmMessage(string messageUUID, string sender, bool messageRead)
 {
     //var message = _context.Message.Where(m => m.Id.ToString() == messageUUID).FirstOrDefault();
     //if(message == null)
     //{
     //  _logger.Error($"Nie znaleziono wiadomości o UUID {messageUUID} .");
     //  return;
     //}
     //message.IsRead = true;
     //var result = await _context.SaveChangesAsync();
     //if(result == 0)
     //{
     //  _logger.Error($"Nie powiodła się oznaczenie wiadomości o UUID {messageUUID} jako przeczytanej.");
     //  return;
     //}
     if (messageRead)
     {
         _logger.Info($"Oznaczanie wiadomości o ID {messageUUID} jako przeczytanej.");
         var msg = _context.Message.Where(m => m.Id == new Guid(messageUUID)).FirstOrDefault();
         if (msg == null)
         {
             _logger.Warn("Nie znaleziono wiadomości o ID " + messageUUID);
         }
         else
         {
             msg.IsRead = messageRead;
             _context.SaveChanges();
         }
     }
     _logger.Info($"Potwierdzenie dostarczenia wiadomości o identyfikatorze {messageUUID}.");
     await Clients.User(sender).SendAsync("ConfirmMessageToSender", messageUUID);
 }
Esempio n. 8
0
        public ActionResult Create(M_PMS M_PMS)
        {
            string actionName = "Create";

            try
            {
                _logger.Log(LogLevel.Trace, actionName + " :: started.");

                if (ModelState.IsValid)
                {
                    using (WebAppDbContext db = new WebAppDbContext())
                    {
                        db.M_PMS.Add(M_PMS);
                        db.SaveChanges();
                    }

                    _logger.Log(LogLevel.Trace, actionName + " :: ended.");

                    Alert("Data Saved Sucessfully!!!", NotificationType.success);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    _logger.Log(LogLevel.Trace, actionName + " :: ended.");
                    return(PartialView("_Create"));
                }
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, actionName + " EXCEPTION :: " + ex.ToString() + " INNER EXCEPTION :: " + ex.InnerException?.ToString());
                Alert("Their is something went wrong!!!", NotificationType.error);
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 9
0
        public ActionResult Delete2(int id, FormCollection collection)
        {
            using (var db = new WebAppDbContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        if (id <= 0)
                        {
                            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                        }

                        var result = db.tbl_Parts.Where(x => x.PartId == id).SingleOrDefault();
                        if (result != null)
                        {
                            //Remove from award
                            db.tbl_Parts.Remove(result);
                            db.SaveChanges();
                            transaction.Commit();
                        }
                        Alert("Record Deleted Permanently!!!", NotificationType.success);
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        Exception(ex);
                        Alert("Their is something went wrong!!!", NotificationType.error);
                        return(RedirectToAction("Index"));
                    }
                }
            }
        }
Esempio n. 10
0
        public JsonResult SaveAsDashboard(string dashboardId, string userId, string roleId)
        {
            var type = "success";
            var msg  = "Dashboard added successfully";

            try
            {
                using (var context = new WebAppDbContext())
                {
                    UserDashboardMapping model = new UserDashboardMapping()
                    {
                        DashboardId       = dashboardId,
                        UserId            = userId,
                        RoleId            = roleId,
                        IsDefault         = "0",
                        InsertionDateTime = DateTime.Now,
                        InsertedBy        = Session[SessionKeys.UserId].ToString()
                    };

                    context.UserDashboardMappings.Add(model);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                type = "error";
                msg  = ex.ToString();
            }

            return(Json(new { type = type, msg = msg }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 11
0
        public ActionResult Edit(int id, tbl_Cage tbl_Cage)
        {
            string actionName = "Edit";

            _logger.Log(LogLevel.Trace, actionName + " :: started.");

            try
            {
                if (ModelState.IsValid)
                {
                    if (id <= 0)
                    {
                        Alert("Invalid Cage Selected.", NotificationType.error);
                        _logger.Log(LogLevel.Trace, actionName + " :: Ended. Invalid cage id : " + id);
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }

                    using (var db = new WebAppDbContext())
                    {
                        var cage = db.tbl_Cage.FirstOrDefault(x => x.CageId == id);
                        if (cage != null && (cage?.CageCode == tbl_Cage.CageCode))
                        {
                            cage.CageName   = tbl_Cage.CageName;
                            cage.Address    = tbl_Cage.Address;
                            cage.Country    = tbl_Cage.Country;
                            cage.City       = tbl_Cage.City;
                            cage.PostalCode = tbl_Cage.PostalCode;
                            cage.Status     = tbl_Cage.Status;

                            cage.ModifiedByUser = Session[SessionKeys.UserId]?.ToString();
                            cage.ModifiedOnDate = DateTime.Now;

                            db.Entry(cage).State = EntityState.Modified;
                            db.SaveChanges();

                            Alert("Record Updated Successfully.", NotificationType.success);
                        }
                        else
                        {
                            Alert("Cage Not Found.", NotificationType.error);
                            _logger.Log(LogLevel.Trace, actionName + " :: Ended. Cage not found for cage id : " + id);
                        }
                    }
                }
                else
                {
                    _logger.Log(LogLevel.Trace, actionName + " :: Ended. Model state is not valid for cage id : " + id);
                    CageViewModels objCageViewModels = GetCage(id);
                    return(PartialView("_Edit", objCageViewModels));
                }
            }
            catch (Exception ex)
            {
                Alert("Something Went Wrong !!!", NotificationType.error);
                _logger.Log(LogLevel.Error, actionName + " EXCEPTION :: " + ex.ToString() + " INNER EXCEPTION :: " + ex.InnerException?.ToString());
                Exception(ex);
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 12
0
        public ActionResult Create(tbl_Cage tbl_Cage)
        {
            string actionName = "Create";

            _logger.Log(LogLevel.Trace, actionName + " :: started.");

            try
            {
                if (ModelState.IsValid)
                {
                    using (var db = new WebAppDbContext())
                    {
                        if (!db.tbl_Cage.Any(x => x.CageCode == tbl_Cage.CageCode))
                        {
                            // Get Current user Id
                            var userId = Session[SessionKeys.UserId]?.ToString();
                            tbl_Cage.CreatedByUser  = userId;
                            tbl_Cage.ModifiedByUser = userId;

                            //Get Current Date & Time.
                            tbl_Cage.CreatedOnDate  = DateTime.Now;
                            tbl_Cage.ModifiedOnDate = DateTime.Now;
                            tbl_Cage.Status         = "Active";

                            db.tbl_Cage.Add(tbl_Cage);
                            db.SaveChanges();


                            Alert("Record Added Successfully !! ", NotificationType.success);
                        }
                        else
                        {
                            _logger.Log(LogLevel.Trace, actionName + " :: Cage code : " + tbl_Cage.CageCode + " already exist.");
                            Alert("Cage code already exist.", NotificationType.error);
                        }
                    }
                }
                else
                {
                    CageViewModels vm = new CageViewModels();

                    SessionKeys.LoadTablesInSession(SessionKeys.Countries, "", "");
                    vm._tbl_Country = ((List <ClassLibrary.Models.tbl_Country>)Session[SessionKeys.Countries]);

                    _logger.Log(LogLevel.Trace, actionName + " :: Model state not valid.");
                    return(PartialView("_Create", vm));
                }
            }
            catch (Exception ex)
            {
                Alert("Their is something went wrong!!!", NotificationType.error);
                _logger.Log(LogLevel.Error, actionName + " EXCEPTION :: " + ex.ToString() + " INNER EXCEPTION :: " + ex.InnerException?.ToString());
                Exception(ex);
            }

            _logger.Log(LogLevel.Trace, actionName + " :: ended.");

            return(RedirectToAction("Index"));
        }
Esempio n. 13
0
        public ActionResult Edit(tbl_Category category)
        {
            WebAppDbContext db = new WebAppDbContext();

            db.Entry(category).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("List"));
        }
Esempio n. 14
0
 // Save Exception log in database
 public void Exception(Exception errorLogs)
 {
     ex.Message       = errorLogs.Message?.ToString();
     ex.StackTrace    = errorLogs.StackTrace?.ToString();
     ex.ExceptionType = errorLogs.GetType()?.Name?.ToString();
     ex.LogTime       = DateTime.Now;
     db.tbl_ErrorLogs.Add(ex);
     db.SaveChanges();
 }
Esempio n. 15
0
        public ActionResult Delete(int id)
        {
            WebAppDbContext db       = new WebAppDbContext();
            var             category = db.tbl_Category.Find(id);

            db.tbl_Category.Remove(category);
            db.SaveChanges();
            return(RedirectToAction("List"));
        }
Esempio n. 16
0
        public bool Add(User user)
        {
            tbl_User us = new tbl_User();

            us.UserId               = user.UserId;
            us.UserName             = user.UserName;
            us.Password             = user.Password;
            us.Email                = user.Email;
            us.Gender               = user.Gender;
            us.IsInterestedInCSharp = user.IsInterestedInCSharp;
            us.IsInterestedInJava   = user.IsInterestedInJava;
            us.IsInterestedInPython = user.IsInterestedInPython;
            us.CityId               = user.CityId;
            us.DOB = user.DOB;
            db.tbl_User.Add(us);
            db.SaveChanges();
            return(true);
        }
Esempio n. 17
0
        public ActionResult ReturnRequestSubmit(int?reqId)
        {
            using (var db = new WebAppDbContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    var vm = new ConfigViewModel();
                    try
                    {
                        if (reqId != null)
                        {
                            var result = db.tbl_Request.Where(x => x.RequestId == reqId).FirstOrDefault();
                            if (result != null)
                            {
                                result.Status = 1;
                                db.SaveChanges();
                                transaction.Commit();
                            }


                            tbl_RequestLog req = new tbl_RequestLog();
                            req.RequestId       = reqId;
                            req.Status          = 1;
                            req.Remarks         = "Again Submitted";
                            req.CurrentDateTime = DateTime.Now;
                            req.UserId          = System.Web.HttpContext.Current.User.Identity.GetUserId();

                            db.tbl_RequestLog.Add(req);
                            db.SaveChanges();
                        }

                        // Alert("Record Deleted Sucessfully!!!", NotificationType.success);
                        return(RedirectToAction("RequestReturn"));
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        Exception(ex);
                        Alert("Their is something went wrong!!!", NotificationType.error);
                        return(RedirectToAction("RequestReturn"));
                    }
                }
            }
        }
Esempio n. 18
0
        public ActionResult EditMOP(M_MOPModel model, int?SiteId, string eswbs)
        {
            string actionName = "EditMOP";

            _logger.Log(LogLevel.Trace, actionName + " :: started.");
            using (var db = new WebAppDbContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    MopViewModels vm = new MopViewModels();
                    try
                    {
                        if (!ModelState.IsValid)
                        {
                            _logger.Log(LogLevel.Trace, actionName + " :: ended.");
                            Alert("Their is something went wrong!!!", NotificationType.error);
                            return(Json(model, JsonRequestBehavior.AllowGet));
                        }
                        if (model.PMS_No != null && model.MOP_No != null && model.SiteId != 0)
                        {
                            var obj = new M_MOP()
                            {
                                SiteId             = model.SiteId,
                                PMS_No             = model.PMS_No,
                                MOP_No             = model.MOP_No,
                                MOP_Desc           = model.MOP_Desc,
                                By_Whom            = model.By_Whom,
                                Periodicity        = model.Periodicity,
                                Period             = model.Period,
                                Doc                = model.Doc,
                                Task_Procedure     = model.Task_Procedure,
                                Safety_Precautions = model.Safety_Precautions,
                            };
                            db.Entry(obj).State = EntityState.Modified;
                        }
                        db.SaveChanges();
                        transaction.Commit();
                        if (SiteId != null && eswbs != null)
                        {
                            vm = GetMopData(SiteId, eswbs);
                        }
                        _logger.Log(LogLevel.Trace, actionName + " :: ended.");

                        return(Json(new { msg = "Data Updated Sucessfully!!!", model = vm.M_MOPModel_List, pmsNo = vm.pmsNo }, JsonRequestBehavior.AllowGet));
                    }
                    catch (Exception ex)
                    {
                        _logger.Log(LogLevel.Error, actionName + " EXCEPTION :: " + ex.ToString() + " INNER EXCEPTION :: " + ex.InnerException?.ToString());
                        transaction.Rollback();
                        Exception(ex);
                        Alert("Their is something went wrong!!!", NotificationType.error);
                        return(Json(vm.M_MOPModel_List));
                    }
                }
            }
        }
Esempio n. 19
0
        public ActionResult DeleteConfirmed(int id)
        {
            Student student = db.Students.Find(id);

            var user = db.Users.Find(student.UserId);

            db.Users.Remove(user);
            db.Students.Remove(student);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 20
0
        public ActionResult Create(tbl_Category category)
        {
            //view to controller, currently we're using args but later we'll see better way
            //controller to view, 3 ways ViewBag, ViewData, TempData
            //ViewBag.Name = name;
            //ViewBag.Desc = description;
            WebAppDbContext db = new WebAppDbContext();

            db.tbl_Category.Add(category);
            db.SaveChanges();
            return(View());
        }
Esempio n. 21
0
        public ActionResult EditMOPItem(M_MOP_ItemsModel model, int?siteId, string pmsNo, string mopNo)
        {
            using (var db = new WebAppDbContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    MopViewModels vm = new MopViewModels();
                    try
                    {
                        if (!ModelState.IsValid)
                        {
                            Alert("Their is something went wrong!!!", NotificationType.error);
                            return(Json(model, JsonRequestBehavior.AllowGet));
                        }
                        if (model != null)
                        {
                            var obj = new M_MOP_ITEMS()
                            {
                                MOP_ItemsId = model.MOP_ItemsId,
                                SiteId      = Convert.ToInt32(model.SiteId),
                                SR_Qty      = model.SR_Qty,
                                PMS_No      = model.PMS_No,
                                MOP_No      = model.MOP_No,
                                Part_No     = model.Part_No,
                            };
                            if (model.NewSelectedPart_No != null)
                            {
                                obj.Part_No = model.NewSelectedPart_No.Trim();
                            }
                            db.Entry(obj).State = EntityState.Modified;
                        }
                        db.SaveChanges();
                        transaction.Commit();

                        if (siteId != null && pmsNo != null && mopNo != null)
                        {
                            vm = GetMopItemData(siteId, pmsNo, mopNo);
                        }

                        //  Alert("Data Saved Sucessfully!!!", NotificationType.success);
                        return(Json(new { msg = "Record Updated Sucessfully!!!", model = vm.M_MOP_ItemsModelList }, JsonRequestBehavior.AllowGet));
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        Exception(ex);
                        //Alert("Their is something went wrong!!!", NotificationType.error);
                        return(Json(vm));
                    }
                }
            }
        }
Esempio n. 22
0
 public int Save()
 {
     try
     {
         return(context.SaveChanges());
     }
     catch (Exception ex)
     {
         var message = GetType().CreateLogMessage(nameof(Save), ex.Message);
         logger.LogError(message);
         throw;
     }
 }
Esempio n. 23
0
        public void AddRating(int eventID, string giverId, string recieverId, int score, DateTime time)
        {
            if (GetAllRatings().ToList().Exists(r => r.GiverId == giverId && r.ReceiverId == recieverId && r.EventId == eventID))
            {
                return;
            }
            else
            {
                MakeNewRating(eventID, giverId, recieverId, score, time);
            }

            dbContext.SaveChanges();
        }
Esempio n. 24
0
        public ActionResult ReturnRequest(int?reqId, string remarks)
        {
            using (var db = new WebAppDbContext())
            {
                try
                {
                    if (reqId != null)
                    {
                        var result = db.tbl_Request.Where(x => x.RequestId == reqId).FirstOrDefault();
                        if (result != null)
                        {
                            result.Status = 3;
                            db.Entry(result).Property(x => x.Status).IsModified = true;

                            db.SaveChanges();
                        }

                        tbl_RequestLog req = new tbl_RequestLog();
                        req.RequestId       = reqId;
                        req.Status          = 3;
                        req.Remarks         = remarks;
                        req.CurrentDateTime = DateTime.Now;
                        req.UserId          = System.Web.HttpContext.Current.User.Identity.GetUserId();

                        db.tbl_RequestLog.Add(req);
                        db.SaveChanges();
                    }

                    Alert("Request return Sucessfully!!!", NotificationType.success);
                    return(RedirectToAction("Inbox"));
                }
                catch (Exception ex)
                {
                    Exception(ex);
                    Alert("Their is something went wrong!!!", NotificationType.error);
                    return(RedirectToAction("Inbox"));
                }
            }
        }
Esempio n. 25
0
        public IActionResult Fruit(SampleViewModel vm)
        {
            if (!string.IsNullOrEmpty(vm.Name))
            {
                if (vm.ModifyIdx == 0)
                {
                    FruitModel fruit = new FruitModel();
                    fruit.name = vm.Name;
                    db.Fruit.Add(fruit);
                    db.SaveChanges();
                }
                else
                {
                    FruitModel fruit = db.Fruit.Find(vm.ModifyIdx);
                    fruit.name = vm.Name;
                    db.Fruit.Update(fruit);
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Fruit"));
        }
Esempio n. 26
0
        public long Insert(Credential entity)
        {
            int a = 0;

            string[] arrEmpId = string.Join(",", entity.SelectedIDRole).Replace(" ", "").Split(',');
            for (int i = 0; i < arrEmpId.Length; i++)
            {
                entity.RoleID = arrEmpId[i];
                db.Credentials.Add(entity);
                db.SaveChanges();
                a = 1;
            }
            return(a);
        }
Esempio n. 27
0
        public long Insert(Employee entity)
        {
            if (CheckUserName(entity.Username) == false && CheckCode(entity.Code) == false)
            {
                if (!string.IsNullOrEmpty(entity.Password))
                {
                    string password = entity.Password;
                    // pass = pass + salt
                    string salt = Crypto.GenerateSalt();
                    //Lưu lại giá trị hash và salt vào db
                    entity.Password = salt;
                    entity.Hash     = Crypto.HashPassword(password + salt);
                }
                entity.Status = true;
                db.Employees.Add(entity);
                db.SaveChanges();
            }

            return(entity.ID);
        }
Esempio n. 28
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            string actionName = "Delete";
            string msg        = String.Empty;

            _logger.Log(LogLevel.Trace, actionName + " :: started.");
            try
            {
                if (id <= 0)
                {
                    Alert("Invalid Cage Selected.", NotificationType.error);
                    _logger.Log(LogLevel.Trace, actionName + " :: Ended. Invalid cage id : " + id);
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                else
                {
                    using (var db = new WebAppDbContext())
                    {
                        var result = db.tbl_Cage.FirstOrDefault(x => x.CageId == id);
                        if (result != null)
                        {
                            result.Status          = "InActive";
                            db.Entry(result).State = EntityState.Modified;
                            db.SaveChanges();

                            msg = "Cage Deleted Successfully.";
                            Alert(msg, NotificationType.success);
                        }
                        else
                        {
                            msg = "Cage Not Found.";
                            Alert(msg, NotificationType.error);
                            _logger.Log(LogLevel.Trace, actionName + " :: Ended. Cage id not found : " + id);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exception(ex);
                msg = "Something Went Wrong !!! ";
                Alert(msg, NotificationType.error);
                _logger.Log(LogLevel.Error, actionName + " EXCEPTION :: " + ex.ToString() + " INNER EXCEPTION :: " + ex.InnerException?.ToString());
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 29
0
        public int InsertStatisticTicketDate()
        {
            if (db.StatisticTickets.Count() != 0)
            {
                var all = from c in db.StatisticTickets select c;
                db.StatisticTickets.RemoveRange(all);
                db.SaveChanges();
            }

            var list = db.OrderDetails.ToList();

            foreach (var item in list)
            {
                DateTime a = item.DailyList.CreatedDate.Date;

                var s = db.StatisticTickets.Where(x => DbFunctions.TruncateTime(x.Datetime) == a && x.Ticket_ID == item.Ticket_ID).ToList();
                if (s.Count == 0)
                {
                    StatisticTicket sta = new StatisticTicket();
                    sta.Datetime     = (DateTime)item.DailyList.CreatedDate;
                    sta.TicketinDate = 1;
                    sta.Employee_ID  = "'" + item.Employee_ID + "'";
                    if (item.DailyList.Taxi == null)
                    {
                        sta.TicketPriceinDate = item.Amount;
                    }
                    else
                    {
                        sta.TicketPriceinDate = item.Amount + item.DailyList.Taxi.Price;
                    }
                    sta.Ticket_ID = (int)item.Ticket_ID;
                    db.StatisticTickets.Add(sta);
                    db.SaveChanges();
                }
                else
                {
                    var sta = db.StatisticTickets.Where(x => DbFunctions.TruncateTime(x.Datetime) == a && x.Ticket_ID == item.Ticket_ID).Select(x => x.ID).ToList();
                    foreach (var itemid in sta)
                    {
                        var statistic = db.StatisticTickets.Find(itemid);
                        if (statistic.Employee_ID.Contains(item.ID.ToString()) != true)
                        {
                            statistic.TicketinDate = statistic.TicketinDate + 1;
                            statistic.Employee_ID  = statistic.Employee_ID + ",'" + item.Employee_ID + "'";

                            statistic.TicketPriceinDate = statistic.TicketPriceinDate + item.Amount;

                            db.SaveChanges();
                        }
                    }
                }
            }
            return(1);
        }
Esempio n. 30
0
        public ActionResult EditChildPart(ChildPartsModel model)
        {
            using (var db = new WebAppDbContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    PartsViewModels vm = new PartsViewModels();
                    try
                    {
                        if (!ModelState.IsValid)
                        {
                            Alert("Their is something went wrong!!!", NotificationType.error);
                            return(Json(model, JsonRequestBehavior.AllowGet));
                        }
                        if (model.ParentPartId != 0 && model.ChildPartId != 0)
                        {
                            var obj = new tbl_ChildParts()
                            {
                                ParentPartId = model.ParentPartId,
                                ChildPartId  = model.ChildPartId,
                                Qty          = model.Qty,
                            };
                            db.Entry(obj).State = EntityState.Modified;
                        }
                        db.SaveChanges();
                        transaction.Commit();

                        int?parentPartId = model.ParentPartId;
                        if (parentPartId != 0)
                        {
                            vm = GetData(parentPartId);
                        }

                        //  Alert("Data Saved Sucessfully!!!", NotificationType.success);
                        return(Json(vm.ChildPartsModel_list, JsonRequestBehavior.AllowGet));
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        Exception(ex);
                        Alert("Their is something went wrong!!!", NotificationType.error);
                        return(Json(vm));
                    }
                }
            }
        }