Пример #1
0
        private void SaveContentProxy(SpecLabEntities _entities,
                                      DatabaseCommand <ContentInfo, object> paramCommand)
        {
            var existContent = (from content in _entities.Contents
                                where content.ContentId == paramCommand.CallingInfo.ContentId
                                select content).FirstOrDefault();

            var loginInfo = SessionUtils.LoginUserInfo;

            if (existContent == null)
            {
                //throw new BusinessException(ErrorCode.ContentIdNotExists, paramCommand.CallingInfo);
                _entities.Contents.Add(new Content()
                {
                    CreateUser  = loginInfo == null ? null : loginInfo.UserId,
                    UpdateUser  = loginInfo == null ? null : loginInfo.UserId,
                    UpdateDate  = DateTime.Now,
                    CreateDate  = DateTime.Now,
                    ContentId   = paramCommand.CallingInfo.ContentId,
                    ContentText = paramCommand.CallingInfo.ContentText
                });
                _entities.SaveChanges();
            }
            else
            {
                existContent.UpdateDate  = DateTime.Now;
                existContent.UpdateUser  = loginInfo == null ? null : loginInfo.UserId;
                existContent.ContentText = paramCommand.CallingInfo.ContentText;
                _entities.SaveChanges();
            }
        }
Пример #2
0
        private void UpdateUserRightsProxy(SpecLabEntities _entities,
                                           DatabaseCommand <UpdateRightParams, bool> paramCommand)
        {
            var listRights = (from u in _entities.UserRights
                              where u.UserInfo.UserId.ToLower().Equals(paramCommand.CallingInfo.UserId.ToLower())
                              select u);

            foreach (var right in listRights)
            {
                _entities.UserRights.Remove(right);
            }
            _entities.SaveChanges();

            foreach (var rightCode in paramCommand.CallingInfo.UpdateRights)
            {
                _entities.UserRights.Add(new UserRight()
                {
                    CreateDate = DateTime.Now,
                    UpdateDate = DateTime.Now,
                    UserId     = paramCommand.CallingInfo.UserId,
                    RightCode  = rightCode.ToString()
                });
            }
            _entities.SaveChanges();

            paramCommand.ReturnValue = true;
        }
Пример #3
0
        private void ChangePasswordProxy(SpecLabEntities _entities,
                                         DatabaseCommand <ChangePassParams, bool> paramCommand)
        {
            paramCommand.ReturnValue = false;

            var selectedUser = (from u in _entities.UserInfoes
                                where u.UserId.ToLower().Equals(paramCommand.CallingInfo.UserId.ToLower())
                                select u).FirstOrDefault();

            if (selectedUser == null)
            {
                throw new BusinessException(ErrorCode.UserIdNotExists);
            }
            else
            {
                string passwordHash = GeneratePasswordHash(
                    paramCommand.CallingInfo.OldPass, selectedUser.PasswordSalt);
                if (!passwordHash.Equals(selectedUser.Password))
                {
                    throw new BusinessException(ErrorCode.PasswordNotMatch);
                }
                else
                {
                    string passwordSalt = Guid.NewGuid().ToString();
                    passwordHash = GeneratePasswordHash(paramCommand.CallingInfo.NewPass, passwordSalt);

                    selectedUser.Password     = passwordHash;
                    selectedUser.PasswordSalt = passwordSalt;

                    _entities.SaveChanges();

                    paramCommand.ReturnValue = true;
                }
            }
        }
Пример #4
0
        private void AddStorageInfoProxy(SpecLabEntities _entities,
                                         DatabaseCommand <ShortStorageInfo, object> paramCommand)
        {
            var existStorage = (from storage in _entities.Storages
                                where storage.StorageId.Equals(paramCommand.CallingInfo.StorageId, StringComparison.OrdinalIgnoreCase)
                                select storage).FirstOrDefault();

            if (existStorage != null)
            {
                throw new BusinessException(ErrorCode.StorageIdExists);
            }
            else
            {
                _entities.Storages.Add(new Storage()
                {
                    UpdateDate    = DateTime.Now,
                    CreateDate    = DateTime.Now,
                    NumberStorage = paramCommand.CallingInfo.NumberStorage,
                    NumColumn     = paramCommand.CallingInfo.NumColumn,
                    NumRows       = paramCommand.CallingInfo.NumRows,
                    StorageId     = paramCommand.CallingInfo.StorageId
                });

                _entities.SaveChanges();
            }
        }
Пример #5
0
        private void DeleteStorageInfoProxy(SpecLabEntities _entities,
                                            DatabaseCommand <string, object> paramCommand)
        {
            var existStorage = (from storage in _entities.Storages
                                where storage.StorageId.Equals(paramCommand.CallingInfo, StringComparison.OrdinalIgnoreCase)
                                select storage).FirstOrDefault();

            if (existStorage == null)
            {
                throw new BusinessException(ErrorCode.StorageIdNotExists, paramCommand.CallingInfo);
            }
            else
            {
                var checkStorageInUse = (from exists in _entities.TubeSamples
                                         where exists.StorageId == paramCommand.CallingInfo
                                         select exists.StorageId);
                if (checkStorageInUse.Any())
                {
                    throw new BusinessException(ErrorCode.StorageIdAlreadyInUse);
                }

                checkStorageInUse = (from exists in _entities.SampleHistories
                                     where exists.StorageId == paramCommand.CallingInfo
                                     select exists.StorageId);
                if (checkStorageInUse.Any())
                {
                    throw new BusinessException(ErrorCode.StorageIdAlreadyInUse);
                }

                _entities.Storages.Remove(existStorage);
                _entities.SaveChanges();
            }
        }
Пример #6
0
        private void UpdateUserProxy(SpecLabEntities _entities,
                                     DatabaseCommand <LoginUserInfo, LoginUserInfo> paramCommand)
        {
            var dbItem = _entities.UserInfoes
                         .FirstOrDefault(c => c.UserId.ToLower().Equals(
                                             paramCommand.CallingInfo.UserId));

            dbItem.FullName = paramCommand.CallingInfo.FullName;
            _entities.SaveChanges();

            paramCommand.ReturnValue = this.GetLoginUserInfo(paramCommand.CallingInfo.UserId);
        }
Пример #7
0
        private void CreateNewUserProxy(SpecLabEntities _entities,
                                        DatabaseCommand <CreateNewUserParams, LoginUserInfo> paramCommand)
        {
            if (paramCommand.CallingInfo.LoginUserInfo.UserId.Equals(CommonConstant.SystemAdmin))
            {
                throw new BusinessException(ErrorCode.UserIdExists);
            }

            var existsUser = _entities.UserInfoes
                             .FirstOrDefault(u => u.UserId.ToLower()
                                             .Equals(paramCommand.CallingInfo.LoginUserInfo.UserId.ToLower()));

            if (existsUser != null)
            {
                throw new BusinessException(ErrorCode.UserIdExists);
            }
            else
            {
                string passwordSalt = Guid.NewGuid().ToString();
                string paswordHash  = GeneratePasswordHash(paramCommand.CallingInfo.Password, passwordSalt);

                var dbItem = new UserInfo()
                {
                    UserId       = paramCommand.CallingInfo.LoginUserInfo.UserId,
                    FullName     = paramCommand.CallingInfo.LoginUserInfo.FullName,
                    CreateDate   = DateTime.Now,
                    UpdateDate   = DateTime.Now,
                    Password     = paswordHash,
                    PasswordSalt = passwordSalt,
                    Status       = UserStatus.Enable.ToString()
                };
                _entities.UserInfoes.Add(dbItem);

                foreach (var rightCode in paramCommand.CallingInfo.LoginUserInfo.Rights)
                {
                    _entities.UserRights.Add(new UserRight()
                    {
                        CreateDate = DateTime.Now,
                        UpdateDate = DateTime.Now,
                        UserId     = paramCommand.CallingInfo.LoginUserInfo.UserId,
                        RightCode  = rightCode.ToString()
                    });
                }

                _entities.SaveChanges();

                paramCommand.ReturnValue = this.GetLoginUserInfo(paramCommand.CallingInfo.LoginUserInfo.UserId);
            }
        }
Пример #8
0
        private void DeleteUserProxy(SpecLabEntities _entities,
                                     DatabaseCommand <string, bool> paramCommand)
        {
            var userInfo = (from u in _entities.UserInfoes
                            where u.UserId.Equals(paramCommand.CallingInfo)
                            select u).FirstOrDefault();

            var listRightDelete = userInfo.UserRights.ToList();

            foreach (var rightDelete in listRightDelete)
            {
                _entities.UserRights.Remove(rightDelete);
            }
            _entities.UserInfoes.Remove(userInfo);
            _entities.SaveChanges();

            paramCommand.ReturnValue = true;
        }
Пример #9
0
        private void UpdateStorageInfoProxy(SpecLabEntities _entities,
                                            DatabaseCommand <ShortStorageInfo, object> paramCommand)
        {
            var existStorage = (from storage in _entities.Storages
                                where storage.StorageId.Equals(paramCommand.CallingInfo.StorageId, StringComparison.OrdinalIgnoreCase)
                                select storage).FirstOrDefault();

            if (existStorage == null)
            {
                throw new BusinessException(ErrorCode.StorageIdNotExists, paramCommand.CallingInfo.StorageId);
            }
            else
            {
                existStorage.NumberStorage = paramCommand.CallingInfo.NumberStorage;
                existStorage.NumRows       = paramCommand.CallingInfo.NumRows;
                existStorage.NumColumn     = paramCommand.CallingInfo.NumColumn;
                _entities.SaveChanges();
            }
        }
        private void UpdateTubeProxy(SpecLabEntities _entities,
                                     DatabaseCommand <UpdateTubeParams, bool> paramCommand)
        {
            var sampleDbItem = (from tube in _entities.TubeSamples
                                where tube.TubeId.Equals(
                                    paramCommand.CallingInfo.TubeId, StringComparison.OrdinalIgnoreCase)
                                select tube).FirstOrDefault();

            if (sampleDbItem == null)
            {
                throw new BusinessException(ErrorCode.TubeIdNotExists);
            }

            // kiểm tra chuyển trạng thái trực tiếp
            TubeSampleType   currentType   = (TubeSampleType)sampleDbItem.TubeType;
            TubeSampleStatus currentStatus = (TubeSampleStatus)sampleDbItem.Status;

            if (paramCommand.CallingInfo.Type == TubeSampleType.InStorage)
            {
                if (paramCommand.CallingInfo.Status == TubeSampleStatus.Remove)
                {
                    if (currentStatus != TubeSampleStatus.Remove)
                    {
                        throw new BusinessException(ErrorCode.TubeUpdateStatusRemove);
                    }
                }
            }
            else if (paramCommand.CallingInfo.Type == TubeSampleType.InUse)
            {
                if (currentType != TubeSampleType.InUse)
                {
                    throw new BusinessException(ErrorCode.TubeUpdateStatusInUse);
                }
            }

            ValidateStorageId(_entities, paramCommand.CallingInfo.StorageId, paramCommand.CallingInfo.LocationNum);

            // check duplicate location
            var checkLocationQuery = (from tube in _entities.TubeSamples
                                      where tube.StorageId == paramCommand.CallingInfo.StorageId &&
                                      tube.LocationNum == paramCommand.CallingInfo.LocationNum &&
                                      tube.Status != (int)TubeSampleStatus.Remove &&
                                      !tube.TubeId.Equals(
                                          paramCommand.CallingInfo.TubeId, StringComparison.OrdinalIgnoreCase)
                                      select tube.TubeId);

            if (checkLocationQuery.Any())
            {
                throw new BusinessException(ErrorCode.StorageLocationUsed,
                                            paramCommand.CallingInfo.StorageId, paramCommand.CallingInfo.LocationNum);
            }

            // check location storage > maximum storage
            checkLocationQuery = (from storage in _entities.Storages
                                  where storage.StorageId == paramCommand.CallingInfo.StorageId &&
                                  storage.NumberStorage < paramCommand.CallingInfo.LocationNum
                                  select storage.StorageId);

            if (checkLocationQuery.Any())
            {
                throw new BusinessException(ErrorCode.StorageLocationOutOfBound,
                                            paramCommand.CallingInfo.StorageId, paramCommand.CallingInfo.LocationNum);
            }

            sampleDbItem.Volume      = paramCommand.CallingInfo.Volume;
            sampleDbItem.StorageId   = paramCommand.CallingInfo.StorageId;
            sampleDbItem.LocationNum = paramCommand.CallingInfo.LocationNum;
            sampleDbItem.Status      = (int)paramCommand.CallingInfo.Status;
            sampleDbItem.TubeType    = (int)paramCommand.CallingInfo.Type;
            sampleDbItem.UpdateDate  = DateTime.Now;

            sampleDbItem.SampleHistories.Add(new SampleHistory()
            {
                HistoryDate = paramCommand.CallingInfo.DateInput,
                Action      = (int)HistoryAction.Update,
                UserId      = paramCommand.CallingInfo.UserInput,
                Status      = (int)paramCommand.CallingInfo.Status,
                TubeType    = (int)paramCommand.CallingInfo.Type,
                Volume      = paramCommand.CallingInfo.Volume,
                StorageId   = paramCommand.CallingInfo.StorageId,
                LocationNum = paramCommand.CallingInfo.LocationNum,
                TubeId      = paramCommand.CallingInfo.TubeId,
                Description = ""
            });

            _entities.SaveChanges();
        }
        private void ImportSampleProxy(SpecLabEntities _entities,
                                       DatabaseCommand <SampleSpecInfo, bool> paramCommand)
        {
            if (paramCommand.CallingInfo.TubeSampleSpecs.Count == 0)
            {
                throw new BusinessException(ErrorCode.ImportNoTube);
            }

            var sampleDbItem = (from sample in _entities.SampleSpecs
                                where sample.SampleSpecId.Equals(
                                    paramCommand.CallingInfo.SampleSpecId, StringComparison.OrdinalIgnoreCase)
                                select sample).FirstOrDefault();

            if (sampleDbItem != null)
            {
                throw new BusinessException(ErrorCode.SampleSpecIdExists);
            }

            var listTubeId           = paramCommand.CallingInfo.TubeSampleSpecs.Select(t => t.TubeId);
            var countTubeIdDuplicate = (from tube in _entities.TubeSamples
                                        where listTubeId.Contains(tube.TubeId)
                                        select tube.TubeId).Count();

            if (countTubeIdDuplicate > 0)
            {
                throw new BusinessException(ErrorCode.TubeIdExists);
            }

            for (int i = 0; i < paramCommand.CallingInfo.TubeSampleSpecs.Count - 1; i++)
            {
                if (paramCommand.CallingInfo.TubeSampleSpecs[i].Volume <= 0)
                {
                    throw new BusinessException(ErrorCode.ImportTubeEmptyVolume);
                }

                for (int j = i + 1; j < paramCommand.CallingInfo.TubeSampleSpecs.Count; j++)
                {
                    if (paramCommand.CallingInfo.TubeSampleSpecs[i].StorageId.Equals(
                            paramCommand.CallingInfo.TubeSampleSpecs[j].StorageId) &&
                        paramCommand.CallingInfo.TubeSampleSpecs[i].LocationNum ==
                        paramCommand.CallingInfo.TubeSampleSpecs[j].LocationNum)
                    {
                        throw new BusinessException(ErrorCode.DuplicateLocationId);
                    }
                }
            }

            for (int i = 0; i < paramCommand.CallingInfo.TubeSampleSpecs.Count; i++)
            {
                var tubeSampleSpecs = paramCommand.CallingInfo.TubeSampleSpecs[i];
                ValidateStorageId(_entities, tubeSampleSpecs.StorageId, tubeSampleSpecs.LocationNum);

                var innerQuery = (from t in _entities.TubeSamples
                                  where t.StorageId == tubeSampleSpecs.StorageId &&
                                  t.LocationNum == tubeSampleSpecs.LocationNum &&
                                  t.Status != (int)TubeSampleStatus.Remove
                                  select t.TubeId);

                if (innerQuery.Any())
                {
                    throw new BusinessException(ErrorCode.StorageLocationUsed, tubeSampleSpecs.StorageId, tubeSampleSpecs.LocationNum);
                }
            }

            var sexValue   = ((char)paramCommand.CallingInfo.Sex).ToString();
            var sampleSpec = new SampleSpec()
            {
                SampleSpecId = paramCommand.CallingInfo.SampleSpecId,
                Age          = paramCommand.CallingInfo.YearOfBirth,
                PatientName  = paramCommand.CallingInfo.PatientName,
                Sex          = sexValue,
                Source       = paramCommand.CallingInfo.LocationId,
                SampleNumber = paramCommand.CallingInfo.TubeSampleSpecs.Count,
                UserInput    = paramCommand.CallingInfo.UserInput,
                CreateDate   = DateTime.Now,
                UpdateDate   = DateTime.Now,
                DateInput    = paramCommand.CallingInfo.DateInput,
            };

            var importDbItem = new Import()
            {
                CreateDate   = DateTime.Now,
                UpdateDate   = DateTime.Now,
                ImportDate   = paramCommand.CallingInfo.DateInput,
                ImportUserId = paramCommand.CallingInfo.UserInput,
                SampleNumber = paramCommand.CallingInfo.TubeSampleSpecs.Count,
                ImportId     = paramCommand.CallingInfo.SampleSpecId
            };

            for (int i = 0; i < paramCommand.CallingInfo.TubeSampleSpecs.Count; i++)
            {
                var tubeSample = paramCommand.CallingInfo.TubeSampleSpecs[i];
                var tubeDbItem = new TubeSample()
                {
                    SampleSpecId = paramCommand.CallingInfo.SampleSpecId,
                    Status       = (int)TubeSampleStatus.Good,
                    TubeType     = (int)TubeSampleType.InStorage,
                    Volume       = tubeSample.Volume,
                    StorageId    = tubeSample.StorageId,
                    LocationNum  = tubeSample.LocationNum,
                    CreateDate   = DateTime.Now,
                    UpdateDate   = DateTime.Now,
                    TubeId       = tubeSample.TubeId,
                    TubeOrder    = i,
                    SampleType   = (int)tubeSample.SampleType
                };
                tubeDbItem.SampleHistories.Add(new SampleHistory()
                {
                    HistoryDate = DateTime.Now,
                    Action      = (int)HistoryAction.Import,
                    UserId      = paramCommand.CallingInfo.UserInput,
                    Status      = (int)TubeSampleStatus.Good,
                    TubeType    = (int)TubeSampleType.InStorage,
                    Volume      = tubeSample.Volume,
                    StorageId   = tubeSample.StorageId,
                    LocationNum = tubeSample.LocationNum,
                    TubeId      = tubeSample.TubeId,
                    Description = ""
                });

                sampleSpec.TubeSamples.Add(tubeDbItem);

                importDbItem.ImportDetails.Add(new ImportDetail()
                {
                    CreateDate  = DateTime.Now,
                    UpdateDate  = DateTime.Now,
                    Status      = (int)TubeSampleStatus.Good,
                    TubeType    = (int)TubeSampleType.InStorage,
                    StorageId   = tubeSample.StorageId,
                    LocationNum = tubeSample.LocationNum,
                    TubeId      = tubeSample.TubeId,
                    Volume      = tubeSample.Volume,
                });
            }

            _entities.SampleSpecs.Add(sampleSpec);
            _entities.Imports.Add(importDbItem);
            _entities.SaveChanges();
        }
        private void ExportSamplesProxy(SpecLabEntities _entities,
                                        DatabaseCommand <ExportSampleParam, bool> paramCommand)
        {
            var checkExists = (from export in _entities.Exports
                               where export.ExportId == paramCommand.CallingInfo.ExportId
                               select export.ExportId);

            if (checkExists.Any())
            {
                throw new BusinessException(ErrorCode.ExportIdExists);
            }

            var exportDbItem = new Export()
            {
                CreateDate     = DateTime.Now,
                UpdateDate     = DateTime.Now,
                ExportDate     = paramCommand.CallingInfo.ExportDate,
                ExportId       = paramCommand.CallingInfo.ExportId,
                ExportToUserId = paramCommand.CallingInfo.ExportForUserId,
                ExportUserId   = paramCommand.CallingInfo.ExportUserId,
                ExportReason   = paramCommand.CallingInfo.ExportReason,
                SampleNumber   = paramCommand.CallingInfo.TubeExportIds.Count
            };

            foreach (var tubeId in paramCommand.CallingInfo.TubeExportIds)
            {
                var tubeDbItem = (from tube in _entities.TubeSamples
                                  where tube.TubeId == tubeId
                                  select tube).FirstOrDefault();

                if (tubeDbItem == null)
                {
                    throw new BusinessException(ErrorCode.TubeIdNotExists);
                }

                exportDbItem.ExportDetails.Add(new ExportDetail()
                {
                    ExportId     = paramCommand.CallingInfo.ExportId,
                    TubeId       = tubeId,
                    Status       = tubeDbItem.Status,
                    TubeType     = tubeDbItem.TubeType,
                    StorageId    = tubeDbItem.StorageId,
                    LocationNum  = tubeDbItem.LocationNum,
                    Volume       = tubeDbItem.Volume,
                    NumberExport = tubeDbItem.NumberExport,
                    CreateDate   = DateTime.Now,
                    UpdateDate   = DateTime.Now
                });

                //tubeDbItem.Status = (int)TubeSampleStatus.InUse;
                tubeDbItem.TubeType      = (int)TubeSampleType.InUse;
                tubeDbItem.NumberExport += 1;
                tubeDbItem.SampleHistories.Add(new SampleHistory()
                {
                    HistoryDate = DateTime.Now,
                    Action      = (int)HistoryAction.Export,
                    UserId      = paramCommand.CallingInfo.ExportUserId,
                    Status      = tubeDbItem.Status,
                    TubeType    = tubeDbItem.TubeType,
                    Volume      = tubeDbItem.Volume,
                    StorageId   = tubeDbItem.StorageId,
                    LocationNum = tubeDbItem.LocationNum,
                    TubeId      = tubeDbItem.TubeId,
                    Description = string.Format("Xuất cho {0} với mục đích {1}.",
                                                paramCommand.CallingInfo.ExportForUserId,
                                                paramCommand.CallingInfo.ExportReason),
                    NumberExport = tubeDbItem.NumberExport,
                });
            }

            _entities.Exports.Add(exportDbItem);
            _entities.SaveChanges();
        }
        private void RemovalSamplesProxy(SpecLabEntities _entities,
                                         DatabaseCommand <RemovalSampleParam, bool> paramCommand)
        {
            var checkExists = (from removal in _entities.Removals
                               where removal.RemovalId == paramCommand.CallingInfo.RemovalId
                               select removal.RemovalId);

            if (checkExists.Any())
            {
                throw new BusinessException(ErrorCode.RemovalIdExists);
            }

            var removalDbItem = new Removal()
            {
                CreateDate    = DateTime.Now,
                UpdateDate    = DateTime.Now,
                RemovalDate   = paramCommand.CallingInfo.RemovalDate,
                RemovalId     = paramCommand.CallingInfo.RemovalId,
                RemovalUserId = paramCommand.CallingInfo.RemovalUserId,
                RemovalReason = paramCommand.CallingInfo.RemovalReason,
                SampleNumber  = paramCommand.CallingInfo.TubeRemovalIds.Count
            };

            foreach (var tubeId in paramCommand.CallingInfo.TubeRemovalIds)
            {
                var tubeDbItem = (from tube in _entities.TubeSamples
                                  where tube.TubeId == tubeId
                                  select tube).FirstOrDefault();

                if (tubeDbItem == null)
                {
                    throw new BusinessException(ErrorCode.TubeIdNotExists);
                }

                removalDbItem.RemovalDetails.Add(new RemovalDetail()
                {
                    RemovalId    = paramCommand.CallingInfo.RemovalId,
                    TubeId       = tubeId,
                    Status       = tubeDbItem.Status,
                    TubeType     = tubeDbItem.TubeType,
                    StorageId    = tubeDbItem.StorageId,
                    LocationNum  = tubeDbItem.LocationNum,
                    Volume       = tubeDbItem.Volume,
                    NumberExport = tubeDbItem.NumberExport,
                    CreateDate   = DateTime.Now,
                    UpdateDate   = DateTime.Now
                });

                tubeDbItem.Status = (int)TubeSampleStatus.Remove;
                tubeDbItem.SampleHistories.Add(new SampleHistory()
                {
                    HistoryDate  = DateTime.Now,
                    Action       = (int)HistoryAction.Remove,
                    UserId       = paramCommand.CallingInfo.RemovalUserId,
                    Status       = tubeDbItem.Status,
                    TubeType     = tubeDbItem.TubeType,
                    Volume       = tubeDbItem.Volume,
                    StorageId    = tubeDbItem.StorageId,
                    LocationNum  = tubeDbItem.LocationNum,
                    TubeId       = tubeDbItem.TubeId,
                    Description  = "",
                    NumberExport = tubeDbItem.NumberExport,
                });
            }

            _entities.Removals.Add(removalDbItem);
            _entities.SaveChanges();
        }