public HttpResponseMessage CreateBranch([FromBody] BranchEntity branchEntity)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                MongoHelper.MongoHelper _mongoHelperobj  = new MongoHelper.MongoHelper("TalentTopper");
                List <BranchEntity>     branchMasterList = new List <BranchEntity>();
                branchMasterList.Add(branchEntity);

                bool data = _mongoHelperobj.InsertMany("BranchMaster", branchMasterList);

                if (data)
                {
                    return(response = Request.CreateResponse(HttpStatusCode.OK, data));
                }
                else
                {
                    return(response = Request.CreateResponse(HttpStatusCode.NotFound, "Unable to save data"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #2
0
        public MessageEntity Create(BranchEntity entity)
        {
            var msgEntity = new MessageEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    int Id = Protector.Int(_uow.Db.Insert(entity));
                    if (Id > 0)
                    {
                        msgEntity.code    = 0;
                        msgEntity.result  = true;
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_OK;

                        _uow.Commit();
                    }
                    else
                    {
                        msgEntity.code    = -2;
                        msgEntity.result  = false;
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_ERR;
                    }
                }
            }
            catch (Exception ex)
            {
                msgEntity.code    = -1;
                msgEntity.result  = false;
                msgEntity.message = ConstantsHandler.ErrorMessage.Message_EX;
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoBranch, "Create : ", ex.ToString());
            }
            return(msgEntity);
        }
Beispiel #3
0
        private void Save()
        {
            if (Helpers.CheckEmpty(errorProvider1, txtName, txtEmail, txtPhone, txtLocation))
            {
                return;
            }
            else
            {
                SaveCompleted = true;
                errorProvider1.Clear();
                BranchEntity branchEntity = new BranchEntity();
                branchEntity.Name      = txtName.Text;
                branchEntity.Email     = txtEmail.Text;
                branchEntity.Phone     = txtPhone.Text;
                branchEntity.Location  = txtLocation.Text;
                branchEntity.Active    = chkActive.Checked;
                branchEntity.CompanyId = (Guid)cboCompany.SelectedValue;

                if (BranchID != Guid.Empty)
                {
                    branchEntity.Id = BranchID;
                    branchEntity.Update(USER.UserName);
                    BranchDao.Update(branchEntity);
                }
                else
                {
                    branchEntity.Id = Guid.NewGuid();
                    branchEntity.Create(USER.UserName);
                    BranchDao.Insert(branchEntity);
                }
            }
        }
        public HttpResponseMessage EditBranch([FromBody] BranchEntity branchEntity)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                MongoHelper.MongoHelper _mongoHelperobj = new MongoHelper.MongoHelper("TalentTopper");

                //FilterDefinition<BsonDocument> filter = "_id:"+ branchEntity.id;

                FilterDefinition <BsonDocument> filter = new BsonDocument("_id", branchEntity.BsonId);

                bool data = _mongoHelperobj.UpdateOne("BranchMaster", filter, branchEntity.ToBsonDocument());

                if (data)
                {
                    return(response = Request.CreateResponse(HttpStatusCode.OK, data));
                }
                else
                {
                    return(response = Request.CreateResponse(HttpStatusCode.NotFound, "Unable to save data"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #5
0
        public void CreateBranch(TBranch branch)
        {
            BranchEntity branchEntity = (BranchEntity)AutoMapper.Mapper.Map <BranchEntity>(branch);

            _context.Branches.Add(branchEntity);
            _context.SaveChanges();
        }
        public async Task <BranchEntity> UpdateBranchAsync(BranchEntity branchEntity, CancellationToken token)
        {
            _dbContext.Branches.Update(branchEntity);
            await _dbContext.SaveChangesAsync(token);

            return(branchEntity);
        }
Beispiel #7
0
        protected void MasterPage_YesClickHandler(object sender, EventArgs e)
        {
            if (ViewState["Delete"] != null)
            {
                try
                {
                    BranchEntity entity = new BranchEntity();
                    entity.OperationId = (int)OperationType.Delete;
                    entity.BranchId    = Utility.GetLong(ViewState["BranchId"]);

                    OperationStatusEntity c = new ConfigrationRepository(SessionContext).UpdateBranch(entity);

                    if (c.StatusResult == true)
                    {
                        ShowInfoMessage(c.InfoMessage);
                        ClearPageControl();
                        FillGrid();
                    }
                    else
                    {
                        ShowErrorMessage(c.InfoMessage);
                    }
                }
                catch (BaseException bex)
                {
                    ShowErrorMessage(bex.Message);
                }
            }
        }
Beispiel #8
0
 public static void Update(BranchEntity branchEntity)
 {
     try
     {
         var com = new SqlCommand("UPDATE_BRANCH", Connect.ToDatabase());
         com.CommandType = CommandType.StoredProcedure;
         com.Parameters.AddWithValue("@ID", branchEntity.Id);
         com.Parameters.AddWithValue("@Name", branchEntity.Name);
         com.Parameters.AddWithValue("@Email", branchEntity.Email);
         com.Parameters.AddWithValue("@Phone", branchEntity.Phone);
         com.Parameters.AddWithValue("@Location", branchEntity.Location);
         com.Parameters.AddWithValue("@Active", branchEntity.Active);
         com.Parameters.AddWithValue("@CompanyId", branchEntity.CompanyId);
         com.Parameters.AddWithValue("@UpdatedBy", branchEntity.UpdatedBy);
         com.Parameters.AddWithValue("@UpdatedDate", branchEntity.UpdatedDate);
         com.ExecuteNonQuery();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.ToString(), @"Could find Store Procedure", MessageBoxButtons.RetryCancel);
     }
     finally
     {
         //if (Connect.ToDatabase().State != ConnectState.Closed)
         {
             Connect.ToDatabase().Close();
         }
     }
 }
Beispiel #9
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Phone,Address,Id,IsActive")] BranchEntity branchEntity)
        {
            if (id != branchEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _branchRepo.UpdateAsync(branchEntity);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BranchEntityExists(branchEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(branchEntity));
        }
Beispiel #10
0
        public static DefaultUser InsertUserDetailed(DbContextOptions <DataContext> options, OrganisationEntity organisation, UserEdit sourceUser)
        {
            var branch = new BranchEntity {
                Id = Guid.NewGuid(), OrganisationId = organisation.Id, Name = "Branch 1"
            };
            var user = new UserEntity
            {
                Id        = sourceUser.Id.Value,
                FirstName = sourceUser.FirstName,
                LastName  = sourceUser.LastName,
                Aliases   = sourceUser.Aliases,
                BranchId  = branch.Id,
                Scope     = sourceUser.Scope,
                Config    = sourceUser.Config,
            };

            using (var context = new DataContext(options))
            {
                context.Branch.Add(branch);
                context.Users.Add(user);
                context.SaveChanges();
            }

            return(new DefaultUser()
            {
                User = user,
                Branch = branch,
                Organisation = organisation
            });
        }
Beispiel #11
0
        public MessageEntity Update(BranchEntity entity)
        {
            var msgEntity = new MessageEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    var data = _uow.Db.SingleOrDefault <BranchEntity>("SELECT * FROM Branch WHERE Id=@0", entity.Id);
                    if (data != null && data.Id == entity.Id)
                    {
                        entity.CreatedBy   = data.CreatedBy;
                        entity.CreatedDate = data.CreatedDate;
                        _uow.Db.Update(entity);
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_OK;
                        msgEntity.result  = true;
                        msgEntity.code    = 0;
                    }
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                msgEntity.result  = false;
                msgEntity.message = ConstantsHandler.ErrorMessage.Message_EX;
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoBranch, "Update : ", ex.ToString());
            }

            return(msgEntity);
        }
        /// <summary>
        /// Gets a branch from its name.
        /// </summary>
        /// <param name="branchName">Name of the branch.</param>
        /// <remarks>
        /// If both local and remote branches exist with the same name, the local branch will be returned.
        /// </remarks>
        /// <returns>
        /// A branch with the name given if it exists; <c>null</c> otherwise.
        /// </returns>
        public BranchEntity GetBranchFromName(string branchName)
        {
            BranchEntity result = null;

            if ((_currentRepository != null) && (_state == RepositoryState.Opened))
            {
                Branch branchFromName = _currentRepository.Branches.FirstOrDefault(b => b.Name == branchName);
                if (branchFromName == null)
                {
                    // Could not find branch from the name given, will try with remote name.
                    string remoteBranchName = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", _remoteName, branchName);
                    branchFromName = _currentRepository.Branches.FirstOrDefault(b => b.Name == remoteBranchName);
                }

                if (branchFromName != null)
                {
                    result               = new BranchEntity();
                    result.Name          = branchFromName.Name;
                    result.IsRemote      = branchFromName.IsRemote;
                    result.IsCurrentHead = branchFromName.IsCurrentRepositoryHead;
                }
            }

            return(result);
        }
 /// <summary>
 /// Locally removes a branch.
 /// </summary>
 /// <param name="branch">The branch to be removed.</param>
 /// <seealso cref="CreateBranch" />
 /// <exception cref="CubedCoDe.Core.BranchCannotBeRemovedException">
 /// The branch to be removed is a remote branch. Remote branches cannot be removed.
 /// or
 /// The branch to be removed is the current head of the repository and can't be removed.
 /// </exception>
 /// <exception cref="BranchDoesNotExistException">The branch to be removed does not exist in this repository.</exception>
 public void RemoveBranch(BranchEntity branch)
 {
     if ((_currentRepository != null) && (_state == RepositoryState.Opened) && (branch != null))
     {
         if (branch.IsRemote)
         {
             throw new BranchCannotBeRemovedException("The branch to be removed is a remote branch. Remote branches cannot be removed.");
         }
         else if (branch.IsCurrentHead)
         {
             throw new BranchCannotBeRemovedException("The branch to be removed is the current head of the repository and can't be removed.");
         }
         else
         {
             Branch branchToRemove = _currentRepository.Branches.FirstOrDefault(b => b.Name == branch.Name && !b.IsRemote);
             if (branchToRemove == null)
             {
                 throw new BranchDoesNotExistException("The branch to be removed does not exist in this repository.");
             }
             else
             {
                 if (branchToRemove.IsCurrentRepositoryHead)
                 {
                     throw new BranchCannotBeRemovedException("The branch to be removed is the current head of the repository and can't be removed.");
                 }
                 else
                 {
                     _currentRepository.Branches.Remove(branchToRemove);
                 }
             }
         }
     }
 }
Beispiel #14
0
        public async Task <TData <string> > SaveForm(BranchEntity entity)
        {
            TData <string> obj = new TData <string>();
            await branchService.SaveForm(entity);

            obj.Data = entity.Id.ParseToString();
            obj.Tag  = 1;
            return(obj);
        }
        /// <summary>
        /// Creates a local branch with the given name.
        /// </summary>
        /// <param name="branchName">Name of the branch to be created.</param>
        /// <returns>
        /// The branch created.
        /// </returns>
        /// <seealso cref="RemoveBranch" />
        /// <remarks>
        /// If there is a remote branch with the exact same name, tracking information will be set up so that the newly created local branch will be tracking the remote branch.
        /// If a local branch already exists with the given name no branch will be created. The existing branch will be fetched and returned in the same manner of <see cref="GetBranchFromName" />.
        /// Once the branch has been created the repository will be switched to point at that branch in the same manner of <see cref="SwitchBranch(string)"/>.
        /// </remarks>
        public BranchEntity CreateBranch(string branchName)
        {
            BranchEntity result = null;

            if ((_currentRepository != null) && (_state == RepositoryState.Opened))
            {
                // Checks if a local branch already exists with the given name and in that case simply gets that branch and returns it.
                if (_currentRepository.Branches.Any(b => b.Name == branchName && !b.IsRemote))
                {
                    result = GetBranchFromName(branchName);
                    SwitchBranch(result);
                }
                else
                {
                    // A local branch doesn't already exist. Gets the remote branch of same name if it exists.
                    BranchEntity remoteBranch = GetBranchFromName(branchName);

                    // Creates the new local branch.
                    Branch newBranch;
                    if (remoteBranch != null)
                    {
                        newBranch = _currentRepository.CreateBranch(branchName, _currentRepository.Branches.First(b => b.Name == remoteBranch.Name && b.IsRemote).Commits.First());
                    }
                    else
                    {
                        newBranch = _currentRepository.CreateBranch(branchName);
                    }

                    if (newBranch != null)
                    {
                        // Sets up tracking information between local branch and remote branch if remote branch exists.
                        if ((remoteBranch != null) && remoteBranch.IsRemote)
                        {
                            _currentRepository.Config.Set <string>(string.Format(CultureInfo.InvariantCulture, "branch.{0}.remote", branchName), _remoteName);
                            _currentRepository.Config.Set <string>(string.Format(CultureInfo.InvariantCulture, "branch.{0}.merge", branchName), string.Format(CultureInfo.InvariantCulture, "refs/heads/{0}", branchName));
                        }

                        result               = new BranchEntity();
                        result.Name          = newBranch.Name;
                        result.IsRemote      = newBranch.IsRemote;
                        result.IsCurrentHead = true;

                        // Switches to the newly created branch and populate result.
                        try
                        {
                            _currentRepository.Checkout(newBranch);
                        }
                        catch (MergeConflictException)
                        {
                            result.IsCurrentHead = false;
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #16
0
        public OperationStatusEntity UpdateBranch(BranchEntity param)
        {
            var parameters = new object[]
            {
                param.OperationId, param.RegionId, param.ZoneId, param.BranchId, param.BranchName
            };

            return(EntityBase.FillObject <OperationStatusEntity>("BranchManage", parameters));
        }
Beispiel #17
0
        public async Task UpdateBranch()
        {
            var options = TestHelper.GetDbContext("UpdateBranch");

            var user1 = TestHelper.InsertUserDetailed(options);

            //Given
            var branch1 = new BranchEntity {
                Id = Guid.NewGuid(), Name = "Branch 1", OrganisationId = user1.Organisation.Id
            };
            var branch2 = new BranchEntity {
                Id = Guid.NewGuid(), Name = "Branch 2", OrganisationId = Guid.NewGuid()
            };

            using (var context = new DataContext(options))
            {
                context.Branch.Add(branch1);
                context.Branch.Add(branch2);

                context.SaveChanges();
            }

            var branch = new Branch()
            {
                Id             = branch1.Id,
                OrganisationId = branch1.OrganisationId,
                Name           = "Branch 1 Updated"
            };

            using (var context = new DataContext(options))
            {
                var auditService = new AuditServiceMock();
                var service      = new BranchService(context, auditService);

                //When
                var scope  = TestHelper.GetScopeOptions(user1);
                var result = await service.UpdateBranch(scope, branch);

                //Then
                Assert.True(result.Success);

                var actual = await context.Branch.FindAsync(branch.Id);

                Assert.Equal(branch.OrganisationId, actual.OrganisationId);
                Assert.Equal(branch.Name, actual.Name);

                //Scope check
                branch.Id             = branch2.Id;
                branch.OrganisationId = branch2.OrganisationId;
                scope  = TestHelper.GetScopeOptions(user1);
                result = await service.UpdateBranch(scope, branch);

                //Then
                Assert.False(result.Success);
            }
        }
Beispiel #18
0
        public async Task <IActionResult> Create([Bind("Name,Phone,Address,Id,IsActive,CreDate")] BranchEntity branchEntity)
        {
            if (ModelState.IsValid)
            {
                await _branchRepo.AddAsync(branchEntity);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(branchEntity));
        }
Beispiel #19
0
        public async Task <IActionResult> Create([Bind("Name,Code,IFSC,Address,Id")] BranchEntity branch)
        {
            if (ModelState.IsValid)
            {
                this.branchManager.InsertBranch(branch);
                await this.unitOfWork.Commit();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
        private BranchEntity MapModelToEntity(Branch model, BranchEntity entity = null)
        {
            if (entity == null)
            {
                entity = new BranchEntity();
            }

            entity.Name = model.Name;

            return(entity);
        }
Beispiel #21
0
        public static BranchEntity typeObjector(Branch branch)
        {
            BranchEntity branchObject = new BranchEntity();

            branchObject.Branchaddress = branch.BranchAddress;
            branchObject.BranchName    = branch.BranchName;
            branchObject.id            = branch.id;
            branchObject.LattitudeX    = int.Parse(branch.LatitudeX.ToString());
            branchObject.LongttitudeY  = int.Parse(branch.LongitudeY.ToString());

            return(branchObject);
        }
Beispiel #22
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Code,IFSC,Address,Id")] BranchEntity branch)
        {
            if (id != branch.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                this.branchManager.UpdateBranch(branch);
                await this.unitOfWork.Commit();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
        public bool Delete(BranchEntity Branch)
        {
            try
            {
                TIMSDBEntities entity    = new TIMSDBEntities();
                tblBranch      tblBranch = entity.tblBranches.Where(x => x.ID == Branch.ID).FirstOrDefault();

                entity.tblBranches.Remove(tblBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #24
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateBusinessData("G1");
                ValidateBusinessData("G2");
                ValidateBusinessData("G3");

                BranchEntity entity = new BranchEntity();

                if (Convert.ToString(ViewState["Add"]) == "Add")
                {
                    entity.OperationId = 1;
                }
                else if (Convert.ToString(ViewState["Update"]) == "Update")
                {
                    entity.OperationId = 2;
                    entity.BranchId    = Utility.GetLong(ViewState["BranchId"]);
                }

                entity.BranchName = txtBranchName.Text.Trim();
                entity.RegionId   = Utility.GetLong(ddlRegion.SelectedValue);
                entity.ZoneId     = Utility.GetLong(ddlZone.SelectedValue);

                OperationStatusEntity c = new ConfigrationRepository(SessionContext).UpdateBranch(entity);

                if (c.StatusResult == true)
                {
                    ShowInfoMessage(c.InfoMessage);
                    ClearPageControl();
                    FillGrid();
                }
                else
                {
                    ShowErrorMessage(c.InfoMessage);
                }
            }
            catch (ValidationException ex)
            {
                ShowErrorMessage(ex.Message);
            }

            catch (BaseException be)
            {
                ShowErrorMessage(be.DisplayMessage);
            }
        }
Beispiel #25
0
        public async Task GetBranch()
        {
            var options = TestHelper.GetDbContext("GetBranch");

            var user1 = TestHelper.InsertUserDetailed(options);

            //Given
            var orgId2  = Guid.NewGuid();
            var branch1 = new BranchEntity {
                Id = Guid.NewGuid(), OrganisationId = user1.Organisation.Id, Name = "Branch 1"
            };
            var branch2 = new BranchEntity {
                Id = Guid.NewGuid(), OrganisationId = orgId2, Name = "Branch 2"
            };

            using (var context = new DataContext(options))
            {
                context.Branch.Add(branch1);
                context.Branch.Add(branch2);

                context.SaveChanges();
            }

            using (var context = new DataContext(options))
            {
                var auditService = new AuditServiceMock();
                var service      = new BranchService(context, auditService);

                //When
                var scope  = TestHelper.GetScopeOptions(user1);
                var actual = await service.GetBranch(scope, branch1.Id);

                //Then
                Assert.Equal(branch1.Id, actual.Id);
                Assert.Equal(branch1.OrganisationId, actual.OrganisationId);
                Assert.Equal(branch1.Name, actual.Name);

                //Scope check
                scope  = TestHelper.GetScopeOptions(user1);
                actual = await service.GetBranch(scope, branch2.Id);

                //Then
                Assert.Null(actual);
            }
        }
        public async Task <ParentEntity> getAsyncParents(SearchModel formdata)
        {
            ChildEntity newChild        = new ChildEntity();
            var         createDateChild = new DateTime(2022, 4, 8, 4, 35, 11);

            newChild.createdDate = createDateChild;
            newChild.name        = "NewChild";
            newChild.sequenceNo  = 32;

            ParentEntity newParent        = new ParentEntity();
            var          createDateParent = new DateTime(2020, 1, 10, 11, 25, 20);

            newParent.createdDate = createDateParent;
            newParent.name        = "NewParent";
            newParent.sequenceNo  = 32;
            newParent.ChildEntity.Add(newChild);

            SubClassEntity newSubClass        = new SubClassEntity();
            var            createSubClassDate = new DateTime(2026, 6, 13, 10, 11, 12);

            newSubClass.createdDate = createSubClassDate;
            newSubClass.name        = "NewSubClass";
            newSubClass.sequenceNo  = 102;

            newParent.SubClassEntity = newSubClass;

            BranchEntity newFirstBranch     = new BranchEntity();
            var          newFirstBranchDate = new DateTime(2023, 2, 14, 14, 22, 15);

            newFirstBranch.createdDate = newFirstBranchDate;
            newFirstBranch.name        = "NewSubClass";
            newFirstBranch.sequenceNo  = 102;
            newParent.FirstBranch.Add(newFirstBranch);


            BranchEntity newSecondBranch     = new BranchEntity();
            var          newSecondBranchDate = new DateTime(2024, 6, 24, 10, 35, 7);

            newSecondBranch.createdDate = newSecondBranchDate;
            newSecondBranch.name        = "NewSubClass";
            newSecondBranch.sequenceNo  = 102;
            newParent.SecondBranch.Add(newSecondBranch);

            return(newParent);
        }
Beispiel #27
0
        /// <summary>
        /// 获取门店的渠道和支付方式
        /// </summary>
        /// <param name="branch"></param>
        private async Task GetBranchBelong(BranchEntity branch)
        {
            List <BranchBelongEntity> branchBelongList = await branchBelongService.GetList(new BranchBelongEntity { BranchId = branch.Id });

            List <BranchBelongEntity> channelBelongList = branchBelongList.Where(p => p.BelongType == BranchBelongTypeEnum.Channel.ParseToInt()).ToList();

            if (channelBelongList.Count > 0)
            {
                branch.ChannelIds = string.Join(",", channelBelongList.Select(p => p.BelongId).ToList());
            }

            List <BranchBelongEntity> PayBelongList = branchBelongList.Where(p => p.BelongType == BranchBelongTypeEnum.Pay.ParseToInt()).ToList();

            if (PayBelongList.Count > 0)
            {
                branch.PayIds = string.Join(",", PayBelongList.Select(p => p.BelongId).ToList());
            }
        }
        public BranchEntity GetSingle(int ID)
        {
            try
            {
                TIMSDBEntities entity = new TIMSDBEntities();

                tblBranch    tblBranch = entity.tblBranches.Where(x => x.ID == ID).FirstOrDefault();
                BranchEntity Branch    = new BranchEntity();
                Branch.ID   = tblBranch.ID;
                Branch.Name = tblBranch.Name;

                return(Branch);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #29
0
        public BranchEntity GetById(int id)
        {
            var entity = new BranchEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    entity = _uow.Db.SingleOrDefault <BranchEntity>("SELECT * FROM Branch WHERE Id=@0", id);
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoBranch, "GetById : ", ex.ToString());
            }

            return(entity);
        }
        public bool Save(BranchEntity Branch)
        {
            try
            {
                tblBranch tblBranch = new tblBranch();

                tblBranch.ID   = Branch.ID;
                tblBranch.Name = Branch.Name;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblBranches.Add(tblBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }