public bool CreateAccount(Account userdata, out bool IsDuplicate)
        {
            bool result = default(bool);

            IsDuplicate = false;
            try
            {
                result = new RepositoryCreator().AccountRepository.CreateAccount(userdata, out IsDuplicate);

                if (result == true && userdata.UserId > default(int))
                {
                    var         connectionString = "AggieGlobal";
                    FarmManager fmanager         = new FarmManager(connectionString);
                    FarmDetail  fDetail          = new FarmDetail();
                    fDetail.FarmId              = default(int);
                    fDetail.FarmName            = "Farm_" + userdata.EmailId;
                    fDetail.FarmSize            = default(int);
                    fDetail.FarmSizeUnit        = string.Empty;
                    fDetail.FarmAddress         = string.Empty;
                    fDetail.FarmEstablishedDate = DateTime.Now;
                    userdata.FarmId             = fmanager.CreateUpdateFarm(fDetail);
                    if (userdata.FarmId > default(int))
                    {
                        fmanager.MapFarmByUserDetail(userdata.FarmId, userdata.UserId);
                    }
                    fmanager.Dispose();
                }
            }
            catch (Exception ex)
            {
                AggieGlobalLogManager.Fatal("AccountManager :: CreateAccount failed :: " + ex.Message);
            }
            return(result);
        }
        public FarmDetailResponse CreateUpdateFarm(FarmDetailResponse requestData)
        {
            int res = default(int);
            FarmDetailResponse responsedata = new FarmDetailResponse();

            try
            {
                if (HttpContext.Current.Session[ApplicationConstant.UserSession] != null)
                {
                    SessionData sessionObject = (SessionData)HttpContext.Current.Session[ApplicationConstant.UserSession];
                    AggieGlobalLogManager.Info("FarmDetailsController :: GetFarmsDetails started ");
                    var        connectionString = "AggieGlobal";
                    var        repo             = new FarmManager(connectionString);
                    FarmDetail response         = new FarmDetail();
                    response.FarmId              = string.IsNullOrEmpty(requestData.FarmId) == true ? default(int) : Convert.ToInt32(EncryptionHelper.AesDecryption(requestData.FarmId, EncryptionKey.LOG));;
                    response.FarmName            = responsedata.FarmName;
                    response.FarmSize            = requestData.FarmSize;
                    response.FarmSizeUnit        = requestData.FarmSizeUnit;
                    response.FarmAddress         = requestData.FarmAddress;
                    response.FarmEstablishedDate = requestData.FarmEstablishedDate;

                    res = repo.CreateUpdateFarm(response);

                    if (res > default(int))
                    {
                        requestData.FarmId  = (res == default(int) ? string.Empty : Convert.ToString(EncryptionHelper.AesEncryption(res.ToString(), EncryptionKey.LOG)));
                        responsedata.Status = ResponseStatus.Successful;
                    }
                    else
                    {
                        responsedata.Status = ResponseStatus.Failed;
                        responsedata.Error  = "Failed to create or update farm";
                    }
                    repo.Dispose();
                }
            }
            catch (Exception ex)
            {
                responsedata.Error  = "Failed to create or update farm";
                responsedata.Status = ResponseStatus.Failed;
                AggieGlobalLogManager.Fatal("FarmDetailsController :: CreateUpdateFarm failed :: " + ex.Message);
            }

            return(requestData);
        }