Beispiel #1
0
        public ActionResult Update(int StaffId, string check, string Status, string type)
        {
            string[] arrUsingServiceLogId = check.Split(',');
            for (int i = 0; i < arrUsingServiceLogId.Count(); i++)
            {
                if (arrUsingServiceLogId[i] != "")
                {
                    var log = new UsingServiceLogDetail();
                    log.StaffId        = StaffId;
                    log.CreatedDate    = DateTime.Now;
                    log.CreatedUserId  = WebSecurity.CurrentUserId;
                    log.ModifiedDate   = DateTime.Now;
                    log.ModifiedUserId = WebSecurity.CurrentUserId;
                    log.AssignedUserId = WebSecurity.CurrentUserId;
                    log.IsDeleted      = false;
                    log.Status         = Status;
                    log.Type           = type;
                    log.UsingServiceId = int.Parse(arrUsingServiceLogId[i], CultureInfo.InvariantCulture);

                    var usingLog = usingServiceLogRepository.GetUsingServiceLogById(int.Parse(arrUsingServiceLogId[i], CultureInfo.InvariantCulture));
                    if (type == "usedservice")
                    {
                        if (usingLog.QuantityUsed < usingLog.Quantity)
                        {
                            usingLog.QuantityUsed = usingLog.QuantityUsed + 1;
                            usingServiceLogRepository.UpdateUsingServiceLog(usingLog);
                            usingServiceLogDetailRepository.InsertUsingServiceLogDetail(log);
                        }
                        else
                        {
                            return(Content("error"));
                        }
                    }
                    else
                    {
                        usingServiceLogDetailRepository.InsertUsingServiceLogDetail(log);
                    }
                }
            }
            return(Content("success"));
        }