Пример #1
0
        public async Task DeleteFieldForceAsync()
        {
            FieldForceAddress address = new FieldForceAddress()
            {
                AddressLine1 = "7101 Richmond Hwy", AddressLine2 = "Apt 2", State = "VA", Zip = "22306", City = "Alexandria", CreatedBy = "Unit Test"
            };
            FieldForce fieldForce = new FieldForce()
            {
                Address = address, Code = "F1", Email = "*****@*****.**", Name = "Faisal AHmed", Phone = "(571)-409-8511", CreatedBy = "Unit Test"
            };

            UnitOfWork.FieldForces.Add(fieldForce);
            await UnitOfWork.CompleteAsync();

            FieldForce dbFieldForce = await UnitOfWork.FieldForces.GetAsync(fieldForce.Id);

            Assert.IsNotNull(dbFieldForce);

            UnitOfWork.FieldForces.Remove(dbFieldForce);

            await UnitOfWork.CompleteAsync();

            dbFieldForce = await UnitOfWork.FieldForces.GetAsync(fieldForce.Id);

            Assert.IsNull(dbFieldForce);
        }
Пример #2
0
        public void InsertFieldForce()
        {
            FieldForceAddress address = new FieldForceAddress()
            {
                AddressLine1 = "7101 Richmond Hwy", AddressLine2 = "Apt 2", State = "VA", Zip = "22306", City = "Alexandria", CreatedBy = "Unit Test"
            };
            FieldForce fieldForce = new FieldForce()
            {
                Address = address, Code = "F1", Email = "*****@*****.**", Name = "Faisal AHmed", Phone = "(571)-409-8511", CreatedBy = "Unit Test"
            };

            UnitOfWork.FieldForces.Add(fieldForce);
            UnitOfWork.Complete();

            FieldForce dbFieldForce = UnitOfWork.FieldForces.Get(fieldForce.Id);

            Assert.IsNotNull(dbFieldForce);

            Assert.AreEqual(dbFieldForce.Name, fieldForce.Name);
            Assert.AreEqual(dbFieldForce.Code, fieldForce.Code);
            Assert.AreEqual(dbFieldForce.Email, fieldForce.Email);
            Assert.AreEqual(dbFieldForce.Phone, fieldForce.Phone);

            Assert.IsNotNull(dbFieldForce.Address);
        }
        public async Task InsertDistributorWithFieldForceAsync()
        {
            Distributor distributor = new Distributor()
            {
                Address = "9420 Key West Avenue", CreatedBy = "Unit Test", Code = "D1", Name = "DrFirst"
            };
            FieldForce fieldForce = new FieldForce()
            {
                Code = "F1", CreatedBy = "Unit Test", Address = new FieldForceAddress()
                {
                    AddressLine1 = "7101 Richmond Hwy", CreatedBy = "Unit Test", City = "Alexandria", State = "VA", Zip = "22306", AddressLine2 = "Apt 2"
                }, Name = "Faisal Ahmed", Phone = "571-409-8588"
            };

            distributor.FieldForces.Add(fieldForce);

            UnitOfWork.Distributors.Add(distributor);

            await UnitOfWork.CompleteAsync();

            Distributor dbDistributor = UnitOfWork.Distributors.Get(distributor.Id);

            Assert.IsNotNull(dbDistributor);

            Assert.AreEqual(distributor.Code, dbDistributor.Code);
            Assert.AreEqual(distributor.Name, dbDistributor.Name);
            Assert.IsTrue(dbDistributor.FieldForces.Count > 0);
            Assert.AreEqual(dbDistributor.FieldForces[0].Code, fieldForce.Code);
            Assert.AreEqual(dbDistributor.FieldForces[0].Name, fieldForce.Name);
        }
Пример #4
0
        public void BindFieldForceList(List <FieldForce> theFieldForceList)
        {
            //ddl_MultiColumn.Items.Clear();
            ddl_MultiColumn.DataSource = null;
            ddl_MultiColumn.DataBind();
            PageVariables.ValueForSelectedText = 3;
            PageVariables.TheFieldForceList    = theFieldForceList;

            List <FieldForce> newfieldforcelist = new List <FieldForce>();

            foreach (FieldForce NewFieldForce in theFieldForceList)
            {
                FieldForce newfieldforce = new FieldForce();
                TextBox    t1            = new TextBox();
                t1.Text = AlignLeft(NewFieldForce.FieldForceName, PageVariables.FirstFieldLength) + " | " + AlignLeft(NewFieldForce.FieldForceCode, PageVariables.SecondFieldLength);
                newfieldforce.FieldForceID   = NewFieldForce.FieldForceID;
                newfieldforce.FieldForceName = t1.Text;
                newfieldforcelist.Add(newfieldforce);
            }
            //
            ddl_MultiColumn.DataSource = newfieldforcelist;

            ddl_MultiColumn.DataTextField  = FieldForceManagement.GetInstance.DisplayMember;
            ddl_MultiColumn.DataValueField = FieldForceManagement.GetInstance.ValueMember;
            ddl_MultiColumn.DataBind();

            ddl_MultiColumn.Items.Insert(0, new ListItem(MicroConstants.DROPDOWNLIST_DEFAULT_ITEMTEXT));
        }
        public static FieldForce GetFieldForceById(int recordId)
        {
            DataRow FieldForceRow = FieldForceDataAccess.GetInstance.GetFieldForceById(recordId);

            FieldForce TheFieldForce = DataRowToObject(FieldForceRow);

            return(TheFieldForce);
        }
Пример #6
0
        public async Task <int> DeleteAsync(int id)
        {
            FieldForce fieldforce = await _unitOfWork.FieldForces.GetAsync(id);

            if (fieldforce == null)
            {
                throw new Exception("Invalid Fieldforce Id");
            }

            _unitOfWork.FieldForces.Remove(fieldforce);
            return(await _unitOfWork.CompleteAsync());
        }
        private void PopulateLoggedOnUserInformation()
        {
            User   TheLoggedOnUser = Micro.Commons.Connection.LoggedOnUser;
            string UserName, FullName, Designation, Location;

            UserName    = MicroConstants.LABEL_DEFAULT_TEXT;
            FullName    = MicroConstants.LABEL_DEFAULT_TEXT;
            Designation = MicroConstants.LABEL_DEFAULT_TEXT;
            Location    = MicroConstants.LABEL_DEFAULT_TEXT;

            if (TheLoggedOnUser == null)
            {
                // DO NOTHING
                // REDIRECT TO LOGIN PAGE
            }
            else
            {
                //TheLoggedOnUser = (User)Session["CurrentUser"];

                UserName = String.Format("{0} ({1})", TheLoggedOnUser.UserName, TheLoggedOnUser.RoleDescription);
                FullName = TheLoggedOnUser.UserReferenceName;

                if (TheLoggedOnUser.UserType == MicroEnums.UserType.FieldForce.GetStringValue())
                {
                    FieldForce f = FieldForceManagement.GetInstance.GetFieldForceById(TheLoggedOnUser.UserReferenceID);
                    Designation = f.FieldForceRankDescription;
                    Location    = f.OfficeName;
                }
                else if (TheLoggedOnUser.UserType == MicroEnums.UserType.Employee.GetStringValue())
                {
                    Employee emp = EmployeeManagement.GetInstance.GetEmployeeByID(TheLoggedOnUser.UserReferenceID);
                    Designation = emp.DesignationDescription;
                    Location    = emp.OfficeName;
                }

                lbl_UserNameValue.Text    = UserName.ToUpper();
                lbl_FullNameValue.Text    = FullName.ToUpper();
                lbl_DesignationValue.Text = Helpers.ToCapitalize(Designation);
                lbl_OfficeValue.Text      = Location;

                //List<Office> TheOfficeList = Micro.BusinessLayer.Administration.OfficeManagement.GetInstance.GetOfficeTreeByUserID(TheLoggedOnUser.UserID);
                //if (TheOfficeList != null)
                //{
                //    if (TheOfficeList.Count > 0)
                //    {
                //        lbl_OfficeValue.Text = String.Format("{0} / {1}", TheOfficeList[0].OfficeName, TheOfficeList[0].ParentOfficeName);
                //    }
                //}
            }
            #endregion
        }
        public static List <FieldForce> GetFieldForceChainByFieldForceID(int fieldForceID)
        {
            List <FieldForce> FieldForceList = new List <FieldForce>();

            DataTable FieldForceTable = FieldForceDataAccess.GetInstance.GetFieldForceChainByFieldForceID(fieldForceID);

            foreach (DataRow dr in FieldForceTable.Rows)
            {
                FieldForce TheFieldForce = DataRowToObject(dr);

                FieldForceList.Add(TheFieldForce);
            }

            return(FieldForceList);
        }
        public static List <FieldForce> GetFieldForceList(bool allOffices = false, bool showDeleted = false)
        {
            List <FieldForce> FieldForceList = new List <FieldForce>();

            DataTable GetFieldForce = FieldForceDataAccess.GetInstance.GetFieldForceList(allOffices, showDeleted);

            foreach (DataRow dr in GetFieldForce.Rows)
            {
                FieldForce TheFieldForce = DataRowToObject(dr);

                FieldForceList.Add(TheFieldForce);
            }

            return(FieldForceList);
        }
        public static List <FieldForce> GetFieldForceByFieldForceRankID(int fieldForceRankID = 0, bool allOffices = false)
        {
            List <FieldForce> FieldForceList = new List <FieldForce>();

            DataTable FieldForceTable = FieldForceDataAccess.GetInstance.GetFieldForceByFieldForceRankID(fieldForceRankID, allOffices);

            foreach (DataRow dr in FieldForceTable.Rows)
            {
                FieldForce TheFieldForce = DataRowToObject(dr);

                FieldForceList.Add(TheFieldForce);
            }

            return(FieldForceList);
        }
        public static FieldForce GetFieldForceByCode(string fieldForceCode)
        {
            FieldForce TheFieldForce;
            DataRow    FieldForceRow = FieldForceDataAccess.GetInstance.GetFieldForceByCode(fieldForceCode);

            if (FieldForceRow != null)
            {
                TheFieldForce = DataRowToObject(FieldForceRow);
            }

            else
            {
                TheFieldForce = new FieldForce();
            }
            return(TheFieldForce);
        }
Пример #12
0
        public async Task <IHttpActionResult> GetFieldForceAsync(int id)
        {
            try
            {
                FieldForce ff = await _unitOfWork.FieldForces.GetAsync(id);

                if (ff == null)
                {
                    _logger.Info(string.Format("No fieldforce found with id", id));
                    return(NotFound());
                }

                return(Ok(new FieldForceDto()
                {
                    Id = ff.Id,
                    Code = ff.Code,
                    Name = ff.Name,
                    AddressLine1 = ff.Address != null ? ff.Address.AddressLine1 : string.Empty,
                    AddressLine2 = ff.Address != null ? ff.Address.AddressLine2 : string.Empty,
                    City = ff.Address != null ? ff.Address.City : string.Empty,
                    State = ff.Address != null ? ff.Address.State : string.Empty,
                    Zip = ff.Address != null ? ff.Address.Zip : string.Empty,
                    Email = ff.Email,
                    Phone = ff.Phone,
                    MarketHierarchyId = ff.MarketHierarchyId,
                    MarketHierarchy = ff.MarketHierarchy != null ? new MarketHierarchyDto()
                    {
                        Code = ff.MarketHierarchy.Code, Name = ff.MarketHierarchy.Name, Id = ff.MarketHierarchy.Id, ParentId = ff.MarketHierarchy.ParentId, Type = ff.MarketHierarchy.Type
                    } : null,
                    Distributors = ff.Distributors != null ? ff.Distributors.Select(d => new DistributorDto()
                    {
                        Id = d.Id, Code = d.Code, Address = d.Address, Name = d.Name
                    }).ToList() : new List <DistributorDto>(),
                    DistributorIds = ff.Distributors != null ? ff.Distributors.Select(d => d.Id).ToList() : new List <int>()
                }));
            }
            catch (Exception ex)
            {
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug(ex);
                    return(InternalServerError(ex));
                }
                return(InternalServerError());
            }
        }
        public int UpdateFieldForceChain(FieldForce theFieldForce)
        {
            int ReturnValue = 0;

            using (SqlCommand InsertCommand = new SqlCommand())
            {
                InsertCommand.CommandType = CommandType.StoredProcedure;
                InsertCommand.Parameters.Add(GetParameter("@FieldForceID", SqlDbType.Int, theFieldForce.FieldForceID));
                InsertCommand.Parameters.Add(GetParameter("@ReportingToFieldForceID", SqlDbType.Int, theFieldForce.ReportingToFieldForceID));
                InsertCommand.Parameters.Add(GetParameter("@ModifiedBy", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.UserID));
                InsertCommand.CommandText = "pCRM_FieldForceChains_UpdateChainSetting";

                ExecuteStoredProcedure(InsertCommand);

                ReturnValue = int.Parse(InsertCommand.Parameters[0].Value.ToString());

                return(ReturnValue);
            }
        }
        public int DeleteFieldForce(FieldForce theFieldForce)
        {
            int ReturnValue = 0;

            using (SqlCommand DeleteCommand = new SqlCommand())
            {
                DeleteCommand.CommandType = CommandType.StoredProcedure;
                DeleteCommand.Parameters.Add(GetParameter("@ReturnValue", SqlDbType.Int, ReturnValue)).Direction = ParameterDirection.Output;
                DeleteCommand.Parameters.Add(GetParameter("@FieldForceID", SqlDbType.Int, theFieldForce.FieldForceID));
                DeleteCommand.Parameters.Add(GetParameter("@ModifiedBy", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.UserID));
                DeleteCommand.CommandText = "pCRM_FieldForces_Delete";

                ExecuteStoredProcedure(DeleteCommand);

                ReturnValue = int.Parse(DeleteCommand.Parameters[0].Value.ToString());

                return(ReturnValue);
            }
        }
        public int InsertFieldForceChain(FieldForce theFieldForce)
        {
            int ReturnValue = 0;

            using (SqlCommand InsertCommand = new SqlCommand())
            {
                InsertCommand.CommandType = CommandType.StoredProcedure;
                InsertCommand.Parameters.Add(GetParameter("@ReturnValue", SqlDbType.Int, ReturnValue)).Direction = ParameterDirection.Output;
                InsertCommand.Parameters.Add(GetParameter("@FieldForceID", SqlDbType.Int, theFieldForce.FieldForceID));
                InsertCommand.Parameters.Add(GetParameter("@ReportingToFieldForceID", SqlDbType.Int, theFieldForce.ReportingToFieldForceID));
                InsertCommand.Parameters.Add(GetParameter("@OfficeID", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.OfficeID));
                InsertCommand.Parameters.Add(GetParameter("@AddedBy", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.UserID));
                InsertCommand.CommandText = "pCRM_FieldForceChains_Insert";

                ExecuteStoredProcedure(InsertCommand);
                ReturnValue = int.Parse(InsertCommand.Parameters[0].Value.ToString());
            }

            return(ReturnValue);
        }
        private void PopulateFieldForce(int fieldForceID)
        {
            FieldForce TheFieldForce = FieldForceManagement.GetInstance.GetFieldForceById(fieldForceID);

            ddl_FieldForceSalutation.Text                 = TheFieldForce.Salutation;
            txt_FieldForceName.Text                       = TheFieldForce.FieldForceName;
            txt_FieldForceFatherName.Text                 = TheFieldForce.FatherName;
            txt_fieldForceDateOfBirth.Text                = DateTime.Parse(TheFieldForce.DateOfBirth).ToString(MicroConstants.DateFormat);
            ddl_FieldForceGender.Text                     = TheFieldForce.Gender;
            ddl_FieldForceReligion.Text                   = TheFieldForce.Religion;
            ddl_FieldForceNationality.Text                = TheFieldForce.Nationality;
            ddl_FieldForceMaritalStatus.Text              = TheFieldForce.MaritalStatus;
            txt_FieldForcePresentTownOrCity.Text          = TheFieldForce.Address_Present_TownOrCity;
            ddl_FieldForcePresentDistrict.SelectedValue   = TheFieldForce.Address_Present_DistrictID.ToString();
            txt_FieldForcePresentState.Text               = TheFieldForce.Address_Present_StateName;
            txt_FieldForcePresentCountry.Text             = TheFieldForce.Address_Present_CountryName;
            txt_FieldForcePermanentTownOrCity.Text        = TheFieldForce.Address_Permanent_TownOrCity;
            ddl_FieldForcePermanentDistrict.SelectedValue = TheFieldForce.Address_Permanent_DistrictID.ToString();
            txt_FieldForcePermanentState.Text             = TheFieldForce.Address_Permanent_StateName;
            txt_FieldForcePermanentCountry.Text           = TheFieldForce.Address_Permanent_CountryName;
            txt_FieldForcePhoneNumber.Text                = TheFieldForce.PhoneNumber;
            txt_FieldForceMobile.Text                     = TheFieldForce.Mobile;
        }
Пример #17
0
        public async Task <IHttpActionResult> SaveFieldForceAsync(FieldForceDto record)
        {
            FieldForce         fieldforce   = null;
            MarketHierarchy    market       = null;
            FieldForceAddress  address      = null;
            List <Distributor> distributors = new List <Distributor>();

            if (ModelState.IsValid)
            {
                try
                {
                    if (record == null)
                    {
                        return(BadRequest());
                    }

                    if (record.MarketHierarchyId.HasValue)
                    {
                        market = await _unitOfWork.MarketHierarchies.GetAsync(record.MarketHierarchyId.Value);

                        if (market == null)
                        {
                            return(BadRequest("Invalid market id"));
                        }
                    }

                    foreach (int id in record.DistributorIds)
                    {
                        Distributor distributor = _unitOfWork.Distributors.Get(id);
                        if (distributor == null)
                        {
                            return(BadRequest("Invalid fistributor id"));
                        }
                        distributors.Add(distributor);
                    }


                    if (record.Id != null)
                    {
                        fieldforce = _unitOfWork.FieldForces.Get(record.Id.Value);
                        if (fieldforce == null)
                        {
                            return(NotFound());
                        }

                        fieldforce.UpdatedBy   = "web:api";
                        fieldforce.UpdatedDate = DateTime.Now;
                    }
                    else
                    {
                        fieldforce = new FieldForce();
                        _unitOfWork.FieldForces.Add(fieldforce);

                        fieldforce.CreatedBy = "web:api";
                    }

                    fieldforce.Distributors.Clear();
                    fieldforce.Distributors = distributors;

                    fieldforce.MarketHierarchy = market;

                    fieldforce.Code  = record.Code;
                    fieldforce.Name  = record.Name;
                    fieldforce.Email = record.Email;
                    fieldforce.Phone = record.Phone;

                    address = new FieldForceAddress();
                    address.AddressLine1 = record.AddressLine1;
                    address.AddressLine2 = record.AddressLine2;
                    address.City         = record.City;
                    address.State        = record.State;
                    address.Zip          = record.Zip;

                    await _unitOfWork.CompleteAsync();

                    return(Ok(new { status = "success" }));
                }
                catch (Exception ex)
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug(ex);
                        return(InternalServerError(ex));
                    }
                    return(InternalServerError());
                }
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
		public int UpdateFieldForce(FieldForce theFieldForce, FieldForceProfile thePhoto, FieldForceProfile theSignature)
		{
			return FieldForceIntegration.UpdateFieldForce(theFieldForce, thePhoto, theSignature);
		}
 public static int DeleteFieldForce(FieldForce theFieldForce)
 {
     return(FieldForceDataAccess.GetInstance.DeleteFieldForce(theFieldForce));
 }
 public static int UpdateFieldForce(FieldForce theFieldForce, FieldForceProfile thePhoto, FieldForceProfile theSignature)
 {
     return(FieldForceDataAccess.GetInstance.UpdateFieldForce(theFieldForce, thePhoto, theSignature));
 }
Пример #21
0
        public async Task <int> SaveAsync(FieldForceViewModel record)
        {
            FieldForce        fieldForce = null;
            FieldForceAddress address    = null;

            if (record.Id != null)
            {
                fieldForce = await _unitOfWork.FieldForces.GetAsync(record.Id.Value);

                if (fieldForce == null)
                {
                    throw new Exception("Invalid Fieldforce Id");
                }

                fieldForce.UpdatedBy   = System.Web.HttpContext.Current.User.Identity.Name;
                fieldForce.UpdatedDate = DateTime.Now;
                address = fieldForce.Address;
            }
            else
            {
                fieldForce           = new FieldForce();
                fieldForce.CreatedBy = System.Web.HttpContext.Current.User.Identity.Name;
            }

            if (address == null)
            {
                address           = new FieldForceAddress();
                address.CreatedBy = System.Web.HttpContext.Current.User.Identity.Name;
            }
            else
            {
                address.UpdatedBy   = System.Web.HttpContext.Current.User.Identity.Name;
                address.UpdatedDate = DateTime.Today;
            }

            fieldForce.Code  = record.Code;
            fieldForce.Name  = record.Name;
            fieldForce.Email = record.Email;
            fieldForce.Phone = record.Phone;

            address.AddressLine1 = record.AddressLine1;
            address.AddressLine2 = record.AddressLine2;
            address.City         = record.City;
            address.State        = record.State;
            address.Zip          = record.ZipCode;

            fieldForce.Address = address;

            fieldForce.MarketHierarchyId = record.MarketHierarchyId;


            if (fieldForce.Distributors != null)
            {
                fieldForce.Distributors.Clear();
            }
            else
            {
                fieldForce.Distributors = new List <Distributor>();
            }

            if (record.DistributorIds != null && record.DistributorIds.Count > 0)
            {
                foreach (int id in record.DistributorIds)
                {
                    Distributor distributor = _unitOfWork.Distributors.Get(id);
                    if (distributor != null)
                    {
                        fieldForce.Distributors.Add(distributor);
                    }
                }
            }

            if (fieldForce.Id <= 0)
            {
                _unitOfWork.FieldForces.Add(fieldForce);
            }

            return(await _unitOfWork.CompleteAsync());
        }
 public static int UpdateFieldForceChain(FieldForce theFieldForce)
 {
     return(FieldForceChainDataAccess.GetInstance.UpdateFieldForceChain(theFieldForce));
 }
 public int UpdateFieldForceChain(FieldForce theFieldForce)
 {
     return(FieldForceChainIntegration.UpdateFieldForceChain(theFieldForce));
 }
		public int DeleteFieldForce(FieldForce theFieldForce)
		{
			return FieldForceIntegration.DeleteFieldForce(theFieldForce);
		}
Пример #25
0
        public void InsertFieldForceWithDistributorAndMarketHierarchy()
        {
            MarketHierarchy nation = new MarketHierarchy()
            {
                Code = "M1", CreatedBy = "Unit Test", Name = "US", Type = MarketHierarchyType.Nation
            };
            MarketHierarchy region = new MarketHierarchy()
            {
                Code = "M2", CreatedBy = "Unit Test", Name = "Virginia", Type = MarketHierarchyType.Region, Parent = nation
            };
            MarketHierarchy territory = new MarketHierarchy()
            {
                Code = "M3", CreatedBy = "Unit Test", Name = "Alexandria", Type = MarketHierarchyType.Territory, Parent = region
            };
            MarketHierarchy route = new MarketHierarchy()
            {
                Code = "M4", CreatedBy = "Unit Test", Name = "Richmond Hwy", Type = MarketHierarchyType.Route, Parent = territory
            };

            Distributor distributor = new Distributor()
            {
                Address = "9420 Key West Avenue", CreatedBy = "Unit Test", Code = "D1", Name = "DrFirst"
            };


            FieldForceAddress address = new FieldForceAddress()
            {
                AddressLine1 = "7101 Richmond Hwy", AddressLine2 = "Apt 2", State = "VA", Zip = "22306", City = "Alexandria", CreatedBy = "Unit Test"
            };
            FieldForce fieldForce = new FieldForce()
            {
                Address = address, Code = "F1", Email = "*****@*****.**", Name = "Faisal AHmed", Phone = "(571)-409-8511", CreatedBy = "Unit Test"
            };

            fieldForce.MarketHierarchy = route;
            fieldForce.Distributors.Add(distributor);


            UnitOfWork.MarketHierarchies.Add(route);
            UnitOfWork.MarketHierarchies.Add(territory);
            UnitOfWork.MarketHierarchies.Add(region);
            UnitOfWork.MarketHierarchies.Add(nation);

            UnitOfWork.Distributors.Add(distributor);

            UnitOfWork.FieldForces.Add(fieldForce);

            UnitOfWork.Complete();

            FieldForce dbFieldForce = UnitOfWork.FieldForces.Get(fieldForce.Id);

            Assert.IsNotNull(dbFieldForce);

            Assert.AreEqual(dbFieldForce.Name, fieldForce.Name);
            Assert.AreEqual(dbFieldForce.Code, fieldForce.Code);
            Assert.AreEqual(dbFieldForce.Email, fieldForce.Email);
            Assert.AreEqual(dbFieldForce.Phone, fieldForce.Phone);

            Assert.IsNotNull(dbFieldForce.MarketHierarchy);
            Assert.AreEqual(dbFieldForce.MarketHierarchy.Id, route.Id);
            Assert.AreEqual(dbFieldForce.MarketHierarchy.Code, route.Code);
            Assert.AreEqual(dbFieldForce.MarketHierarchy.Name, route.Name);

            Assert.AreEqual(1, dbFieldForce.Distributors.Count);
            Assert.IsNotNull(dbFieldForce.Distributors[0]);
            Assert.AreEqual(dbFieldForce.Distributors[0].Id, distributor.Id);
            Assert.AreEqual(dbFieldForce.Distributors[0].Name, distributor.Name);
            Assert.AreEqual(dbFieldForce.Distributors[0].Name, distributor.Name);
        }
        public int UpdateFieldForce(FieldForce theFieldForce, FieldForceProfile thePhoto, FieldForceProfile theSignature)
        {
            int ReturnValue = 0;

            using (SqlCommand UpdateCommand = new SqlCommand())
            {
                UpdateCommand.CommandType = CommandType.StoredProcedure;
                UpdateCommand.Parameters.Add(GetParameter("@ReturnValue", SqlDbType.Int, ReturnValue)).Direction = ParameterDirection.Output;
                UpdateCommand.Parameters.Add(GetParameter("@FieldForceID", SqlDbType.Int, theFieldForce.FieldForceID));
                UpdateCommand.Parameters.Add(GetParameter("@FieldForceRankID", SqlDbType.Int, theFieldForce.FieldForceRankID));
                UpdateCommand.Parameters.Add(GetParameter("@FieldForceRankDescription", SqlDbType.VarChar, theFieldForce.FieldForceRankDescription));
                UpdateCommand.Parameters.Add(GetParameter("@ReportingToFieldForceID", SqlDbType.Int, theFieldForce.ReportingToFieldForceID));
                UpdateCommand.Parameters.Add(GetParameter("@Salutation", SqlDbType.VarChar, theFieldForce.Salutation));
                UpdateCommand.Parameters.Add(GetParameter("@FieldForceName", SqlDbType.VarChar, theFieldForce.FieldForceName));
                UpdateCommand.Parameters.Add(GetParameter("@FatherName", SqlDbType.VarChar, theFieldForce.FatherName));
                UpdateCommand.Parameters.Add(GetParameter("@HusbandName", SqlDbType.VarChar, theFieldForce.HusbandName));
                UpdateCommand.Parameters.Add(GetParameter("@Gender", SqlDbType.VarChar, theFieldForce.Gender));
                UpdateCommand.Parameters.Add(GetParameter("@MaritalStatus", SqlDbType.VarChar, theFieldForce.MaritalStatus));
                UpdateCommand.Parameters.Add(GetParameter("@DateOfBirth", SqlDbType.VarChar, theFieldForce.DateOfBirth));
                UpdateCommand.Parameters.Add(GetParameter("@Age", SqlDbType.Int, theFieldForce.Age));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Present_TownOrCity", SqlDbType.VarChar, theFieldForce.Address_Present_TownOrCity));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Present_Landmark", SqlDbType.VarChar, theFieldForce.Address_Present_Landmark));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Present_PinCode", SqlDbType.VarChar, theFieldForce.Address_Present_PinCode));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Present_DistrictID", SqlDbType.Int, theFieldForce.Address_Present_DistrictID));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Permanent_TownOrCity", SqlDbType.VarChar, theFieldForce.Address_Permanent_TownOrCity));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Permanent_Landmark", SqlDbType.VarChar, theFieldForce.Address_Permanent_Landmark));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Permanent_PinCode", SqlDbType.VarChar, theFieldForce.Address_Permanent_PinCode));
                UpdateCommand.Parameters.Add(GetParameter("@Address_Permanent_DistrictID", SqlDbType.Int, theFieldForce.Address_Permanent_DistrictID));
                UpdateCommand.Parameters.Add(GetParameter("@PhoneNumber", SqlDbType.VarChar, theFieldForce.PhoneNumber));
                UpdateCommand.Parameters.Add(GetParameter("@Mobile", SqlDbType.VarChar, theFieldForce.Mobile));
                UpdateCommand.Parameters.Add(GetParameter("@EMailID", SqlDbType.VarChar, theFieldForce.EMailID));
                UpdateCommand.Parameters.Add(GetParameter("@FieldForce_Qualification", SqlDbType.VarChar, theFieldForce.FieldForce_Qualification));
                UpdateCommand.Parameters.Add(GetParameter("@Occupation", SqlDbType.VarChar, theFieldForce.Occupation));
                UpdateCommand.Parameters.Add(GetParameter("@Nationality", SqlDbType.VarChar, theFieldForce.Nationality));
                UpdateCommand.Parameters.Add(GetParameter("@Religion", SqlDbType.VarChar, theFieldForce.Religion));
                UpdateCommand.Parameters.Add(GetParameter("@Caste", SqlDbType.VarChar, theFieldForce.Caste));
                UpdateCommand.Parameters.Add(GetParameter("@NomineeName", SqlDbType.VarChar, theFieldForce.NomineeName));
                UpdateCommand.Parameters.Add(GetParameter("@Nominee_Permanent_TownOrCity", SqlDbType.VarChar, theFieldForce.Nominee_Permanent_TownOrCity));
                UpdateCommand.Parameters.Add(GetParameter("@Nominee_Permanent_Landmark", SqlDbType.VarChar, theFieldForce.Nominee_Permanent_Landmark));
                UpdateCommand.Parameters.Add(GetParameter("@Nominee_Permanent_PinCode", SqlDbType.VarChar, theFieldForce.Nominee_Permanent_PinCode));
                UpdateCommand.Parameters.Add(GetParameter("@Nominee_Permanent_DistrictID", SqlDbType.Int, theFieldForce.Nominee_Permanent_DistrictID));
                UpdateCommand.Parameters.Add(GetParameter("@NomineeRelationship", SqlDbType.VarChar, theFieldForce.NomineeRelationship));
                UpdateCommand.Parameters.Add(GetParameter("@NomineeAge", SqlDbType.Int, theFieldForce.NomineeAge));
                UpdateCommand.Parameters.Add(GetParameter("@IsNomineeACoWorker", SqlDbType.Bit, theFieldForce.IsNomineeACoWorker));
                UpdateCommand.Parameters.Add(GetParameter("@Nominee_Qualification", SqlDbType.VarChar, theFieldForce.Nominee_Qualification));
                UpdateCommand.Parameters.Add(GetParameter("@BankBranchID", SqlDbType.Int, theFieldForce.BankBranchID));
                UpdateCommand.Parameters.Add(GetParameter("@BankAccountNumber", SqlDbType.VarChar, theFieldForce.BankAccountNumber));
                UpdateCommand.Parameters.Add(GetParameter("@PhotoKeyName", SqlDbType.VarChar, thePhoto.SettingKeyName));
                UpdateCommand.Parameters.Add(GetParameter("@PhotoKeyDescription", SqlDbType.VarChar, thePhoto.SettingKeyDescription));
                UpdateCommand.Parameters.Add(GetParameter("@PhotoKeyValue", SqlDbType.VarBinary, thePhoto.SettingKeyValue));
                UpdateCommand.Parameters.Add(GetParameter("@PhotoKeyReference", SqlDbType.VarChar, thePhoto.SettingKeyReference));
                UpdateCommand.Parameters.Add(GetParameter("@SignatureKeyName", SqlDbType.VarChar, theSignature.SettingKeyName));
                UpdateCommand.Parameters.Add(GetParameter("@SignatureKeyDescription", SqlDbType.VarChar, theSignature.SettingKeyDescription));
                UpdateCommand.Parameters.Add(GetParameter("@SignatureKeyValue", SqlDbType.VarBinary, theSignature.SettingKeyValue));
                UpdateCommand.Parameters.Add(GetParameter("@SignatureKeyReference", SqlDbType.VarChar, theSignature.SettingKeyReference));
                UpdateCommand.Parameters.Add(GetParameter("@OfficeID", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.OfficeID));
                UpdateCommand.Parameters.Add(GetParameter("@ModifiedBy", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.UserID));
                UpdateCommand.CommandText = "pCRM_FieldForces_Update";

                ExecuteStoredProcedure(UpdateCommand);

                ReturnValue = int.Parse(UpdateCommand.Parameters[0].Value.ToString());

                return(ReturnValue);
            }
        }
        public static FieldForce DataRowToObject(DataRow dr)
        {
            FieldForce TheFieldForce = new FieldForce();

            TheFieldForce.FieldForceID                = int.Parse(dr["FieldForceID"].ToString());
            TheFieldForce.FieldForceCode              = dr["FieldForceCode"].ToString();
            TheFieldForce.FieldForceRankID            = int.Parse(dr["FieldForceRankID"].ToString());
            TheFieldForce.FieldForceRankName          = dr["FieldForceRankName"].ToString();
            TheFieldForce.FieldForceRankDescription   = dr["FieldForceRankDescription"].ToString();
            TheFieldForce.ReportingToFieldForceRankID = int.Parse(MicroGlobals.ReturnZeroIfNull(dr["ReportingToFieldForceRankID"].ToString()));
            if (TheFieldForce.ReportingToFieldForceRankID > 0)
            {
                TheFieldForce.ReportingToFieldForceRankName        = dr["ReportingToFieldForceRankName"].ToString();
                TheFieldForce.ReportingToFieldForceRankDescription = dr["ReportingToFieldForceRankDescription"].ToString();
                TheFieldForce.ReportingToFieldForceID   = int.Parse(dr["ReportingToFieldForceID"].ToString());
                TheFieldForce.ReportingToFieldForceCode = dr["ReportingToFieldForceCode"].ToString();
                TheFieldForce.ReportingToFieldForceName = dr["ReportingToFieldForceName"].ToString();
            }
            TheFieldForce.Salutation                     = dr["Salutation"].ToString();
            TheFieldForce.FieldForceName                 = dr["FieldForceName"].ToString();
            TheFieldForce.FatherName                     = dr["FatherName"].ToString();
            TheFieldForce.HusbandName                    = dr["HusbandName"].ToString();
            TheFieldForce.Gender                         = dr["Gender"].ToString();
            TheFieldForce.MaritalStatus                  = dr["MaritalStatus"].ToString();
            TheFieldForce.DateOfBirth                    = DateTime.Parse(dr["DateOfBirth"].ToString()).ToString(MicroConstants.DateFormat);
            TheFieldForce.Age                            = int.Parse(MicroGlobals.ReturnZeroIfNull(dr["Age"].ToString()));
            TheFieldForce.Address_Present_TownOrCity     = dr["Address_Present_TownOrCity"].ToString();
            TheFieldForce.Address_Present_Landmark       = dr["Address_Present_Landmark"].ToString();
            TheFieldForce.Address_Present_PinCode        = dr["Address_Present_PinCode"].ToString();
            TheFieldForce.Address_Present_DistrictID     = int.Parse(dr["Address_Present_DistrictID"].ToString());
            TheFieldForce.Address_Present_DistrictName   = dr["Address_Present_DistrictName"].ToString();
            TheFieldForce.Address_Present_StateName      = dr["Address_Present_StateName"].ToString();
            TheFieldForce.Address_Present_CountryName    = dr["Address_Present_CountryName"].ToString();
            TheFieldForce.Address_Permanent_TownOrCity   = dr["Address_Permanent_TownOrCity"].ToString();
            TheFieldForce.Address_Permanent_Landmark     = dr["Address_Permanent_Landmark"].ToString();
            TheFieldForce.Address_Permanent_PinCode      = dr["Address_Permanent_PinCode"].ToString();
            TheFieldForce.Address_Permanent_DistrictID   = int.Parse(dr["Address_Permanent_DistrictID"].ToString());
            TheFieldForce.Address_Permanent_DistrictName = dr["Address_Permanent_DistrictName"].ToString();
            TheFieldForce.Address_Permanent_StateName    = dr["Address_Permanent_StateName"].ToString();
            TheFieldForce.Address_Permanent_CountryName  = dr["Address_Permanent_CountryName"].ToString();
            TheFieldForce.PhoneNumber                    = dr["PhoneNumber"].ToString();
            TheFieldForce.Mobile                         = dr["Mobile"].ToString();
            TheFieldForce.EMailID                        = dr["EMailID"].ToString();
            TheFieldForce.FieldForce_Qualification       = dr["FieldForce_Qualification"].ToString();
            TheFieldForce.Occupation                     = dr["Occupation"].ToString();
            TheFieldForce.Nationality                    = dr["Nationality"].ToString();
            TheFieldForce.Religion                       = dr["Religion"].ToString();
            TheFieldForce.Caste                          = dr["Caste"].ToString();
            TheFieldForce.NomineeName                    = dr["NomineeName"].ToString();
            TheFieldForce.Nominee_Permanent_TownOrCity   = dr["Nominee_Permanent_TownOrCity"].ToString();
            TheFieldForce.Nominee_Permanent_Landmark     = dr["Nominee_Permanent_Landmark"].ToString();
            TheFieldForce.Nominee_Permanent_PinCode      = dr["Nominee_Permanent_PinCode"].ToString();
            TheFieldForce.Nominee_Permanent_DistrictID   = int.Parse(dr["Nominee_Permanent_DistrictID"].ToString());
            TheFieldForce.Nominee_Permanent_DistrictName = dr["Nominee_Permanent_DistrictName"].ToString();
            TheFieldForce.Nominee_Permanent_StateName    = dr["Nominee_Permanent_StateName"].ToString();
            TheFieldForce.Nominee_Permanent_CountryName  = dr["Nominee_Permanent_CountryName"].ToString();
            TheFieldForce.NomineeRelationship            = dr["NomineeRelationship"].ToString();
            TheFieldForce.NomineeAge                     = int.Parse(MicroGlobals.ReturnZeroIfNull(dr["NomineeAge"].ToString()));
            TheFieldForce.IsNomineeACoWorker             = bool.Parse(dr["IsNomineeACoWorker"].ToString());
            TheFieldForce.Nominee_Qualification          = dr["Nominee_Qualification"].ToString();
            TheFieldForce.BankBranchID                   = int.Parse(MicroGlobals.ReturnZeroIfNull(dr["BankBranchID"].ToString()));
            if (TheFieldForce.BankBranchID > 0)
            {
                TheFieldForce.BankName          = dr["BankName"].ToString();
                TheFieldForce.BankBranchName    = dr["BankBranchName"].ToString();
                TheFieldForce.BankAccountNumber = dr["BankAccountNumber"].ToString();
            }
            TheFieldForce.HasServiceComplain = bool.Parse(dr["HasServiceComplain"].ToString());
            TheFieldForce.OfficeID           = int.Parse(dr["OfficeID"].ToString());
            TheFieldForce.OfficeName         = dr["OfficeName"].ToString();
            return(TheFieldForce);
        }
 public int InsertFieldForceChain(FieldForce theFieldForce)
 {
     return(FieldForceChainIntegration.InsertFieldForceChain(theFieldForce));
 }